Skip to content

Commit

Permalink
The Mars rover appears at the same latitude but a longitude 180
Browse files Browse the repository at this point in the history
degrees on the other side.
  • Loading branch information
hemalvarambhia committed Oct 30, 2023
1 parent c082076 commit 177ae68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/mars_rover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def execute(commands)
when 'f'
new_location = forwards(location)
if @map.located_at_north_pole? new_location.coordinates
Location.new(coordinates: Coordinates.new(x: 0, y: 9), direction: 'S')
Location.new(coordinates: Coordinates.new(x: 18, y: 8), direction: 'S')
else
new_location
end
Expand Down
4 changes: 2 additions & 2 deletions spec/moving_forwards_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ def self.mars_rover(map: Map.new(x_domain: (0..10), y_domain: (0..10)), located_

context 'moving towards the north and south pole' do
it 'can move to the north pole of the planet' do
mars_rover = a_mars_rover(located_at: Location.new(coordinates: Coordinates.new(x: 0, y: 9), direction: 'N'))
mars_rover = a_mars_rover(located_at: Location.new(coordinates: Coordinates.new(x: 0, y: 8), direction: 'N'))

mars_rover.execute(['f'])

top_edge = Coordinates.new(x: 0, y: 10)
top_edge = Coordinates.new(x: 18, y: 8)
expect(mars_rover).to be_located_at(top_edge)
end

Expand Down

0 comments on commit 177ae68

Please sign in to comment.