Tasks made simple with minimal code snippets. Some of them might be useful for coding challenges:
-
Check balanced Brackets
import re s=re.sub(r'[^\[\]\(\)]','',input()) p='' while not s==p:p=re.sub(r'\[\]|\(\)','',s);s=p print(str(s==''))
-
Reverse words in string
#Ruby puts gets.split.map(&:reverse)*' ' #Python3 print(*print(*[i[::-1]for i in input().split()]))