I think he built equivalent of a logic circuit to do the arithmetic, but using apparently the simulated mechanical physics within the game. The simulated ropes, levers, pulleys, or whatever, he navigates in the second half are the implementation of that "circuit". A lot of work.