PuzzleNode Solution in Ruby