Skip to main content
added 38 characters in body
Source Link
Manish Kundu
  • 5.3k
  • 2
  • 15
  • 47

Python 2, 74 7272 69 bytes

def f(s):
 try:eval(exec s.replace(')','),'));print s
 except:f(s[-1]+s[s[1:-1]]+s[0])

Try it online!Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added , after every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus, -3 bytes thanks to dingledooper

54 bytes if it's allowed to take ( and ), instead of ( and ) 👀51 bytes if it's allowed to take ( and ), instead of ( and ) 👀

Python 2, 74 72 bytes

def f(s):
 try:eval(s.replace(')','),'));print s
 except:f(s[-1]+s[:-1])

Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added , after every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus

54 bytes if it's allowed to take ( and ), instead of ( and ) 👀

Python 2, 74 72 69 bytes

def f(s):
 try:exec s.replace(')','),');print s
 except:f(s[1:]+s[0])

Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added , after every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus, -3 bytes thanks to dingledooper

51 bytes if it's allowed to take ( and ), instead of ( and ) 👀

added 243 characters in body
Source Link
Manish Kundu
  • 5.3k
  • 2
  • 15
  • 47

Python 2, 74 72 bytes

def f(s):
 try:eval(s.replace(')','),'));print s
 except:f(s[-1]+s[:-1])

Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added , after every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus

54 bytes if it's allowed to take ( and ), instead of ( and ) 👀

Python 2, 74 72 bytes

def f(s):
 try:eval(s.replace(')','),'));print s
 except:f(s[-1]+s[:-1])

Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added , after every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus

Python 2, 74 72 bytes

def f(s):
 try:eval(s.replace(')','),'));print s
 except:f(s[-1]+s[:-1])

Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added , after every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus

54 bytes if it's allowed to take ( and ), instead of ( and ) 👀

added 47 characters in body
Source Link
Manish Kundu
  • 5.3k
  • 2
  • 15
  • 47

Python 2, 7474 72 bytes

def f(s):
 try:eval(s.replace(')(',')+(,'));print s
 except:f(s[-1]+s[:-1])

Try it online!Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added +, operationafter every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus

Python 2, 74 bytes

def f(s):
 try:eval(s.replace(')(',')+('));print s
 except:f(s[-1]+s[:-1])

Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added + operation so that the expression is valid.

Takes ( and ) instead of [ and ].

Python 2, 74 72 bytes

def f(s):
 try:eval(s.replace(')','),'));print s
 except:f(s[-1]+s[:-1])

Try it online!

Tried a similar approach to Jo King's Raku answer by evaluating the bracket string, only difference being an added , after every ) so that the expression is valid.

Takes ( and ) instead of [ and ].

-2 bytes thanks to Sisyphus

Source Link
Manish Kundu
  • 5.3k
  • 2
  • 15
  • 47
Loading