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