Setting up a coordinate system with the starting point at the origin (0, 0), where East is the positive x-direction and North is the positive y-direction.
Starting position: (0, 0), initially facing East
Drives 20 km towards the East:
Position: (20, 0)
Direction: East
Turns to the right and drives 3 km:
Turning right from East means facing South
Position: (20, -3)
Direction: South
Turns to his right (towards West) and drives 3 km:
Turning right from South means facing West
Position: (20 - 3, -3) = (17, -3)
Direction: West
Turns to his left and walks 2 km:
Turning left from West means facing South
Position: (17, -3 - 2) = (17, -5)
Direction: South
Turns to his right and travels 17 km:
Turning right from South means facing West
Position: (17 - 17, -5) = (0, -5)
Direction: West
Distance from starting point (0, 0) to final position (0, -5):
d=(0−0)2+(−5−0)2
d=0+25
d=5 km
Therefore, he is 5 km from his starting point.