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