Codington
0 of 6 problems solved • 0%

Exercise prompt

Find the Widest Swing

Example

Compare changes rather than peaks to see which measurement moved more.

rooms = {"hall": (10, 14), "loft": (1, 9)} widths = {room: high - low for room, (low, high) in rooms.items()} print(widths) # {'hall': 4, 'loft': 8}

The highest peak and the widest swing can belong to different groups. For dates, ISO strings sort in chronological order.

Your task

Implement widest_swing(days). Each ISO date key maps to a daily summary with numeric low and high values. Return the date with the greatest difference between high and low. If several dates tie, use the earliest date. Return None for an empty dictionary.

widest_swing({"2026-03-02": {"low": 4, "high": 6}, "2026-03-01": {"low": -2, "high": 3}}) # "2026-03-01"