Back to Practice
#0045
Direction Sense Final Position
EasyAptitude10 min10 XP
Problem
A person walks 4 km south, then 3 km east, then 4 km north. How far and in which direction is the person from the starting point?
Why This Matters
Direction questions become simple if you draw axes instead of trying to imagine the whole path in your head.
Examples
Example 1
InputSouth 4, East 3, North 4
Output3 km east
South 4 and north 4 cancel out. Only east 3 remains.
Constraints
- Assume straight-line movement along cardinal directions.
- Report the final displacement from the starting point.
CodeReasoning
A person walks 4 km south, then 3 km east, then 4 km north. How far and in which direction is the person from the starting point?
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Cancel vertical movement
InputS 4, E 3, N 4
Expected3 km east
The vertical displacement becomes zero.
Hidden Test Categories
Final position diagonal from startOnly one direction movementMore west than east