 # Untitled

a guest
Oct 9th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Question: Imagine you are on a grid. Start at location (0, 0), facing north. Turn right. Take 1 step. Turn right. Take 6 steps. Turn right. Take 1 step. Turn right. Take 2 steps. Take 4 steps. Are you back at location (0, 0)?
2. Steps:
3. - Turn right, facing east. Am at x = 0. y = 0.
4. - Take 1 step facing east. Moving east increases x coordinate. Current x location is 0. 0 + 1 = 1. Am at x = 1, y = 0.
5. - Turn right, facing south. Am at x = 1, y = 0
6. - Take 6 steps facing south. Moving south decreases y coordinate. Current y location is 0. 0 - 6 = -6. Am at x = 1, y = -6.
7. - Turn right, facing west. Am at x = 1, y = -6.
8. - Take 2 steps facing west. Moving west decreases x coordinate. Current x location is 1. 1 - 2 = -1. Am at x = -1, y = -6.
9. - Take 4 steps facing west. Moving west decreases x coordinate. Current x location is -1. -1 - 4 = -5. Am at x = -5, y = -6.
10. - Query was "Are you back at location (0, 0)?". This means x = 0, y = 0. I am at x = -5, y = -6. This is not the same as x = 0, y = 0. The answer to the query is no.
12.
13. ===
14.
15. Question: Imagine you are on a grid. Start at location (0, 0), facing north. Take 2 steps. Take 3 steps. Turn right. Turn right. Take 4 steps. Take 1 step. Are you back at location (0, 0)?
16. Steps:
17. - Take 2 steps facing north. Moving north increases y coordinate. Current y location is 0. 0 + 2 = 2. Am at x = 0, y = 2.
18. - Take 3 steps facing north. Moving north increases y coordinate. Current y location is 2. 2 + 3 = 5. Am at x = 0, y = 5.
19. - Turn right, facing east. Am at x = 0, y = 5.
20. - Turn right, facing south. Am at x = 0, y = 5.
21. - Take 4 steps facing south. Moving south decreases y coordinate. Current y location is 5. 5 - 4 = 1. Am at x = 0, y = 1.
22. - Take 1 step facing south. Moving south decreases y coordinate. Current y location is 1. 1 - 1 = 0. Am at x = 0, y = 0.
23. - Query was "Are you back at location (0, 0)?". This means x = 0, y = 0. I am at x = 0, y = 0. This is the same as x = 0, y = 0. The answer to the query is yes.