Solution to level 35 in Untrusted: http://alex.nisnevich.com/untrusted/