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