We get a big file like


and after replacing however many millions of <script> tags only the flag should remain.

Did this one under severe time pressure, which of course means you try the worst solutions first. Tried a regex which replaced two layers of nested strings at the same time. It starts out great, but quickly falls into quicksand because it seems there are around 16 or so (?) huge “towers” of nested strings (like a degenerate tree where each node only has one child).

So from there I moved on to the second worst solution, where I took the resulting string with these “towers” and sliced them off at the base simply by string-scanning forward on <> characters, not caring about anything else, reasoning that surely they could not be part of the flag.

It worked and got the flag, but it was a shitty ad-hoc solution.

The right solution (I realize now) would have been to just write simple, straightforward loop that keeps a stack of strings at each level. I had discarded this idea from the get-go, because I misread the size of the file (~64MB) as ~640MB, assuming that a Python loop that iterates per character was totally out of the question.