A man faces north. He turns 90 degrees clockwise and then 135 degrees anticlockwise. Which direction is he facing now?
North-west. Net rotation = 90 clockwise - 135 anticlockwise = 45 degrees anticlockwise from north, which is north-west.
Explain it simply
Treat clockwise turns as positive and anticlockwise turns as negative, add them up, and apply the net turn to the starting direction. Use a compass with eight points: each step between neighbouring points (N, NE, E, SE, S, SW, W, NW) is 45 degrees.
Example
Question: Facing north. 90 degrees clockwise, then 135 degrees anticlockwise.
- Net = +90 - 135 = -45 degrees, that is 45 degrees anticlockwise.
- From north, 45 degrees anticlockwise = north-west.
Step-by-step check: north + 90 clockwise = east. East - 135 anticlockwise: east to north (90), then 45 more to north-west.
Bearings view (clockwise from north): 0 + 90 - 135 = -45, which is 315 degrees, north-west.
const dirs = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
const bearing = (((0 + 90 - 135) % 360) + 360) % 360;
console.log(bearing); // Output: 315
console.log(dirs[bearing / 45]); // Output: NWWhat to say in the interview
"I add the turns with clockwise as positive: plus 90 minus 135 is minus 45. Forty-five degrees anticlockwise from north is north-west."
Common mistakes
- Turning in the wrong direction for 'anticlockwise'.
- Not reducing a negative bearing to the 0 to 360 range.