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