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