Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 469 Bytes

CodeSnippets.md

File metadata and controls

17 lines (12 loc) · 469 Bytes

Tasks made simple with minimal code snippets. Some of them might be useful for coding challenges:

  1. 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==''))
    
  2. Reverse words in string

     #Ruby
     puts gets.split.map(&:reverse)*' '
     
     #Python3
     print(*print(*[i[::-1]for i in input().split()]))