Build a prerequisite-aware learning planner
Create a planner that accepts lessons, durations, and prerequisite edges, then produces a valid order and a daily plan under a time budget. Treat prerequisites as a directed graph and detect cycles before claiming a schedule is possible.
data class Lesson(val id: String, val minutes: Int)
data class Prerequisite(val before: String, val after: String)
sealed interface PlanResult {
data class Ready(val days: List<List<String>>) : PlanResult
data class Invalid(val reason: String) : PlanResult
}
Validate unique IDs, positive durations, existing edge endpoints, and the chosen rule for lessons longer than a daily budget. Use Kahn's algorithm for prerequisite order with deterministic tie-breaking. Then pack ready lessons according to a clearly documented heuristic.
Do not claim the heuristic minimizes the number of days: precedence-constrained scheduling and packing objectives can be substantially harder than topological ordering. A valid schedule is a different guarantee from an optimal one.
Acceptance checks
Verify each lesson appears exactly once, prerequisites are satisfied under your same-day ordering policy, and each day's total respects the budget. Test independent lessons, a dependency chain, a diamond, cycles, duplicate IDs, missing prerequisites, oversized lessons, and empty input.
For small instances, compare day counts with an exhaustive search to measure the heuristic's gap. For large instances, report runtime, peak memory, graph size, and deterministic reproducibility. Use Long for accumulated totals where needed.
Deliverable: working CLI, sample input/output, tests, an analysis of each stage, and a README distinguishing correctness guarantees from optimization goals.