Capstone: Meridian's Day Planner
In short: this capstone chains the section together — the knapsack lesson's capacity check, the bitmask lesson's exact-tour table, and its walk-back — to score every possible set of jobs by the shortest round that visits them, and keep the best legal one. The twist is that the most profitable set on paper can be illegal (too heavy), and the best legal set can leave out the richest job, because profit depends on both what you load and how far driving it costs, and neither greedy rule alone sees both.

Every morning the planner is given the day's jobs, one van, a weight limit, and the cost of driving a kilometre. Each job sits at a stop and pays a fee, and the streets between stops are one-way. A job at a far stop might pay less than the fuel it takes to get there, and the van can't carry everything. Which jobs to take and in what order to drive them can't be decided separately. The best set depends on the round, and the round depends on the set.
This capstone puts the section together. You'll use knapsack's capacity check, the bitmask tour table and the walk-back, and then ask a question that none of the earlier lessons did: how do you know the plan you were handed is any good?
Recognising the shape
Every lesson in this section was the same idea, a table of subproblem answers filled in dependency order. The part that changed was the state. Before writing any code, name the state:
| The question sounds like… | State | Lesson |
|---|---|---|
| "choose items under a limit" | item × capacity (× a second limit) | knapsack |
| "move across a map, only forwards" | row × column (× direction, × resource) | grids |
| "a hierarchy, each part depends on its children" | node × a few flags | trees |
| "which of a small set is done, and where am I" | set × current item | bitmask |
| "best of the last k" | index, with a deque over the window | optimisation |
| "a contiguous stretch" | left end × right end | interval DP (not covered here) |
The day planner is a set problem, since there are at most eight stops and the rest of the round depends only on which are done and where the van is. It also has a limit on top, which is where the knapsack check comes in.