4 ms·
I solved this in a couple of hours just now with pen and paper after looking at the input program. There seem to be only 3 types of instructions: - either you
by gadiyar 5y ago
I solved this in a couple of hours just now with pen and paper after looking at the input program. There seem to be only 3 types of instructions:
- either you unconditionally append a new digit to Z
- or you conditionally either:
- replace the last digit in Z with a new one
- or you remove the last digit in Z
The only way you would end up with a 0 at the end is if every one of those conditions evaluates such that you always remove the last digit of Z.
Each of those 7 conditions constrains 2 of the input digits at a time, and once you list out those conditions, you're done.