Advertisement

**Not a member of Pastebin yet?**

**, it unlocks many cool features!**

__Sign Up__- 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)?
- Steps:
- - Turn right, facing east. Am at x = 0. y = 0.
- - Take 1 step facing east. Moving east increases x coordinate. Current x location is 0. 0 + 1 = 1. Am at x = 1, y = 0.
- - Turn right, facing south. Am at x = 1, y = 0
- - Take 6 steps facing south. Moving south decreases y coordinate. Current y location is 0. 0 - 6 = -6. Am at x = 1, y = -6.
- - Turn right, facing west. Am at x = 1, y = -6.
- - Take 2 steps facing west. Moving west decreases x coordinate. Current x location is 1. 1 - 2 = -1. Am at x = -1, y = -6.
- - Take 4 steps facing west. Moving west decreases x coordinate. Current x location is -1. -1 - 4 = -5. Am at x = -5, y = -6.
- - 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.
- Final answer: No
- ===
- 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)?
- Steps:
- - Take 2 steps facing north. Moving north increases y coordinate. Current y location is 0. 0 + 2 = 2. Am at x = 0, y = 2.
- - Take 3 steps facing north. Moving north increases y coordinate. Current y location is 2. 2 + 3 = 5. Am at x = 0, y = 5.
- - Turn right, facing east. Am at x = 0, y = 5.
- - Turn right, facing south. Am at x = 0, y = 5.
- - Take 4 steps facing south. Moving south decreases y coordinate. Current y location is 5. 5 - 4 = 1. Am at x = 0, y = 1.
- - Take 1 step facing south. Moving south decreases y coordinate. Current y location is 1. 1 - 1 = 0. Am at x = 0, y = 0.
- - 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.
- Final answer: Yes
- ===
- Question: Imagine you are on a grid. Start at location (0, 0), facing north. Turn left. Take 9 steps. Take 3 steps. Turn right. Are you back at location (0, 0)?

Advertisement

Add Comment

Please,

**to add comment**__Sign In__Advertisement