Skip to main content
3 of 4
added 170 characters in body
dzaima
  • 20.3k
  • 2
  • 42
  • 75

#SOGL V0.12, 12 11 bytes ↔]»:l{Ƨ()øŗ Try it Here!

Explanation:

↔            mirror characters
 ]           do ... while the top of stack is truthy
  »            put the last letter at the start
   :           duplicate it
    l{         length times do
      Ƨ()        push "()"
         ø       push ""
          ŗ      replace ["()" with ""]
             if the string left on stack is empty (aka all matched parentheses could be removed), then stop the while loop

Note: l{ could be replaced with ( for 10 bytes, but, sadly, it isn't implemented.

dzaima
  • 20.3k
  • 2
  • 42
  • 75