Nasa Rover problem's solution in Ruby 1.9.2-p290