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