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