Ground pass planner
A spacecraft in low orbit can only talk to a ground station while it is above that station's horizon, a few minutes at a time. The flight dynamics team sends the pass times per station. Mission planning wants them as one timeline: which passes are long enough for a full data dump, in order, and where the silent stretches are.
Build the planner.
Finish stage 1 to unlock this stage.
Collect every pass longer than MIN_MINUTES, from every station, into windows, as (start, end, station, minutes) with the times parsed by datetime.fromisoformat(). Sort them by start time and print:
Contact windows over 8 minutes: 06:30:00-06:44:00 Usuda 14.0 min 08:02:10-08:13:40 Kiruna 11.5 min 08:10:00-08:19:30 Svalbard 9.5 min 09:48:00-09:59:10 Svalbard 11.2 min 11:20:30-11:31:00 Kiruna 10.5 min 12:50:00-13:02:45 Toruń 12.8 min
Because each tuple starts with the start time, windows.sort() puts them in time order. {start:%H:%M:%S} formats just the time.
Finish stage 1 to unlock this stage.
Find the longest gap with no station in contact, between the end of one window and the start of the next, and print it after the list:
Longest gap without contact: 08:19:30 to 09:48:00 (1:28:30)
Windows can overlap: Svalbard's first pass starts before Kiruna's ends. Keep the latest end seen so far in latest_end, and count a gap only when the next window starts after it.
Hints
Iterating Over Dictionary
# How long a single day lasts on each planet, measured in Earth hours
day_hours = {
"Mercury": 1408,
"Venus": 5832,
"Earth": 24,
"Mars": 24.6,
"Jupiter": 9.9,
}
# A plain for loop walks the keys
for planet in day_hours:
print("Planet:", planet)
# .values() walks the values instead
total = 0
for hours in day_hours.values():
total = total + hours
print("All five days added together:", total, "hours")
# .items() hands you the key and the value at the same time
for planet, hours in day_hours.items():
print(f"{planet}: one day is {round(hours / 24, 2)} Earth days")
# sorted() walks the same keys in a different order
for planet in sorted(day_hours):
print(planet, "->", day_hours[planet], "hours")
Separate arguments with commas. They're passed on every Run as sys.argv[1:].