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