Steepest Climb

Data with PythonEasy+10 XP+10

Steepest Climb

A café owner looks at a line chart of visitors per day. She wants to know where the line climbs most steeply from one point to the next.

Task: write steepest_climb(days, visitors). days holds the day names in order, and visitors[i] is the count for days[i].

Return a list of two day names, [from_day, to_day], for the pair of neighbouring days with the biggest rise in visitors.

  • Only compare each day with the day right after it.
  • If two climbs tie for biggest, return the earlier one.
  • If the line never rises (it only falls or stays flat), or there are fewer than two days, return [].

Examples

days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
visitors = [120, 95, 180, 110, 60, 210, 130]
returns ['Fri', 'Sat']
days = ["Mon", "Tue", "Wed"]
visitors = [50, 40, 30]
returns []

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run