docs(nav): add docstrings

This commit is contained in:
Ensign Pixel 2026-09-06 07:44:00 +02:00
commit 41e657b6aa

3
nav.py
View file

@ -35,16 +35,19 @@ LAUNCH_FUEL = 380.0 # tonnes of fuel to escape Earth's gravity
def distance(a, b):
"""Return the distance between two neighboring waypoints."""
if (a, b) in DISTANCES:
return DISTANCES[(a, b)]
return DISTANCES[(b, a)]
def legs(route):
"""Return the legs (pairs of consecutive waypoints) of a route."""
return [(route[i], route[i + 1]) for i in range(len(route) - 1)]
def plan(destination):
"""Return route, distance, travel time (days) and fuel (t)."""
route = ROUTES[destination]
total = 0.0
fuel = 0.0