part 1
solution
my solution to the example can be viewed and tried on
uiuapad
this
is the variant that reads the file. i simply uploaded my downloaded input, and it will read the contents of the file to produce a string just like the one in the example, thus the code from the example also works.