You will write a small route planner. A route is a list of legs, and each leg is a pair (distance in km, bearing in degrees).
The idea. A leg moves east and north. Add the parts. The bearing of the end point comes from math.atan2(east, north), turned into degrees and brought into the range to with % 360.
Your tasks.
parts(route). Return the pair (east, north) of the end point.distance(route). Return the straight-line distance from the start to the end point.bearing(route). Return the bearing of the end point from the start, between and .Run your code once to unlock the worked solution.
Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…