← back to unit
Challenge
# breaking it down advanced
Shortest Chores First
One washing machine, everyone's laundry waiting. Each person waits until THEIR load finishes. In what order is the total waiting smallest? Shortest first! 🧺
You get the load durations. Order them shortest-first, then compute each person's finish time (the running total when their load ends). Print the SUM of all finish times — the smallest total waiting possible.
Example:
Input: durations = [3, 1, 2]
Output: 10
Sorted shortest-first gives [1, 2, 3]. The finish times are 1, 1+2=3, 1+2+3=6 — summing 1 + 3 + 6 = 10.
💡 need a hint?
brk-shortest-chores-first.py🔒 given lines are locked — write your code in between
loading...