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