Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6 lines solution solution in Clear category for Remove Brackets by kdim
from re import search, sub
def remove_brackets(line: str) -> str:
p, l = r'\(\)|\[\]|\{\}', len(line)
check = lambda x: check(sub(p, '', x)) if bool(search(p, x)) else x
subst = lambda x: ''.join(a * int(b) for a, b in zip(line, f'{x:0{l}b}'))
return max((subst(i) for i in range(2 ** l) if not check(subst(i))), key=len)
Feb. 4, 2021
Comments: