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