Ruby implementation of Digitas Labyrinth puzzle