Capstone — Festival Planner
In short: this capstone tests recognising which technique a problem is asking for, then wiring the pieces together so each one's output feeds the next. "Most things that fit, with a swap argument" is greedy. "Best total, where choices interact through a budget or overlaps" is dynamic programming. "Every answer, not just the best one" is backtracking. The same planner uses all three, because its three questions are three different shapes wearing the same costume — acts and a festival night.

Booking the main stage by fans, not count
Tunebox Festival is one night with a main stage, a side stage and a hard
curfew. Every act applies with [name, start, end, fans]; the house DJ's
crate holds [title, minutes] tracks. The main stage wants the most fans,
and earliest-finish greedy — which books the most acts — says nothing
about weight:
The mistake: that books three acts for 300 + 400 + 500 = 1200 fans, but Kade and Zed alone draw 1300. The exchange argument that proved earliest-finish swaps one act for another — it keeps the count the same, not the fans, so it says nothing about weights. Maximising weight means weighing every act against everything it excludes, which is a DP.
Sort by end time. Let best[i] be the most fans from the first i acts.
Act i either sits out (best[i-1]) or plays (fans + best[p], where p
is how many acts end by the time act i starts — exactly the acts
compatible with it). Because end times are sorted, p is a binary search:
from bisect import bisect_right
ends = [60, 120, 150]
print(bisect_right(ends, 120))best = [0, 300, 800, 0]
p = 1 # only Nova ends by 60, when Luma starts
best[3] = max(best[2], 400 + best[p]) # sit out, or play Luma's 400 after the best of the first p
print(best[3])Here is the full table for all five acts, then the walk back that reads the
lineup out of it. Pointer p marks the last act that ends before the
current one starts:
Each best[i] weighs one act against everything it overlaps, which no single greedy rule can do.
best[0] = 0, because with no acts nobody comes. 6 cells. At index 0.