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