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