When I did my submission, I did the filtering as an “external preprocessing” step with grep and did the rest in Python. It reminded me of previous years, where I had to do some “external postprocessing” with Wolfram Alpha sometimes.
Instead of this hybrid approach, the code I give below runs entirely in the Unix shell, without any Python. This was the only day this year where I did not use Python for everything.
grep -o 'mul([0-9]\+,[0-9]\+)' | sed ' s/mul(/s += / s/,/ * / s/)// $s/$/\ns/ ' | bc
grep -o -e 'mul([0-9]\+,[0-9]\+)' -e 'do()' -e 'don'\''t()' | sed ' 1s/^/x = 1\n/ s/do()/x = 1/ s/don'\''t()/x = 0/ s/mul(/s += x * / s/,/ * / s/)// $s/$/\ns/ ' | bc
2024-12-27
text/gemini; lang=en
This content has been proxied by September (ba2dc).