Samuel
@samuel.fm
Leetle #7 2/6 14:44 [19 lines] 🟩🟩🟩🟩🟩πŸŸ₯ 🟩🟩🟩🟩🟩🟩 leetle.app pretty pleased with that one
3 34
David Buchanan
after submitting my smart solution I had a great idea for a dumb-but-works solution - iteratively .replace() pairs until the string stops getting shorter, then see if it's empty
1 2
David Buchanan
yup Leetle #7 3/6 3:40 [3 lines] ⚠️⚠️⚠️⚠️⚠️⚠️ βŒ›οΈβŒ›οΈβŒ›οΈβŒ›οΈβŒ›οΈβŒ›οΈ 🟩🟩🟩🟩🟩🟩 (funnily enough it took me longer to get it right than the "smart" solution)
2
reece.py
Leetle #7 X/6 16:53 πŸŸ₯🟩πŸŸ₯🟩πŸŸ₯🟩 πŸŸ₯🟩🟩🟩πŸŸ₯πŸŸ₯ 🟩🟩🟩🟩🟩πŸŸ₯ 🟩🟩🟩🟩🟩πŸŸ₯ πŸŸ₯🟩πŸŸ₯🟩πŸŸ₯🟩 πŸŸ₯🟩πŸŸ₯🟩πŸŸ₯πŸŸ₯ terrible. was trying to keep the logic to more-or-less one line lol. took two more tries after this and an interpreter to get the and clause right but i got there with this monstrosity
Python code:

def solve(s):
  st = []
  try:
    return all(t := [y for y in [(st.append({"(": ")", "[": "]", "{": "}"}[x]) if x in "{([" else st.pop() == x) for x in s] if y is not None]) and (bool(len(t)) or not(s))
  except Exception:
    return False