picoCTF 2018 - Script Me Writeup

We can connect to the challenge via the command nc 2018shell2.picoctf.com 7866, getting this:

The brackets groups act like cells, and the bigger cell “eats” the smaller one. Understanding this, we can write a simple Python script which parses the expression, finds the answer and eventually prints the flag.
The code is this:

And the output is:

So the flag is picoCTF{5cr1pt1nG_l1k3_4_pRo_45ca3f85}.