Skip to content

Instantly share code, notes, and snippets.

View Sivakumar00's full-sized avatar
🎯
I can do this all day

SivaKumar00 Sivakumar00

🎯
I can do this all day
View GitHub Profile
This robot roams around a 2D grid. It starts at (0, 0) facing North. After each time it moves, the robot rotates 90 degrees clockwise. Given the amount the robot has moved each time, you have to calculate the robot's final position.
To illustrate, if the robot is given the movements 20, 30, 10, 40 then it will move:
20 steps North, now at (0, 20)
30 steps East, now at (30, 20)
10 steps South. now at (30, 10)
40 steps West, now at (-10, 10)
...and will end up at coordinates (-10, 10).