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