avoid resultant lateral movement except at equator

if x and y represent lat/long, the angular distance we move
along the lines of longitude will vary depending on latitude.
main
Daniel Barlow 2023-01-22 19:07:25 +00:00
parent 570fe8dadc
commit bcd833e26b
1 changed files with 4 additions and 4 deletions

View File

@ -96,9 +96,9 @@
(expect "Moves north when pointing south and asked to move backward"
(execute r [:b]) {:x 3 :y 3 :direction :s}))
(let [r (rover 3 2 :e)]
(let [r (rover 3 0 :e)]
(expect "Moves west when pointing east and asked to move backward"
(execute r [:b]) {:x 2 :y 2 :direction :e}))
(execute r [:b]) {:x 2 :y 0 :direction :e}))
(let [r (rover 2 4 :e)]
(expect "Rotates to south when pointing east and asked to turn right"
@ -114,8 +114,8 @@
(let [r (rover 1 1 :s)]
(expect "Multiple commands are executed in the right order"
(execute r [:l :l :f :f :f :r :f])
{:x 2 :y 4 :direction :e}))
(execute r [:l :l :f :f :f :r :f :b])
{:x 1 :y 4 :direction :e}))
"if we travel west past x=-180, x becomes positive 180"