I Know What I Need, But I Don't Know How To Build It

Pick the thing you need. Then derive it: meaning, state, operations, rules, examples, representation, pseudocode — and only then the code, one rung at a time.

I need XWhat is X?What must it remember?What can happen to it?What must always hold?ExamplesRepresent the stateWhich structure?Each operationPseudocodeImplement oneTest with examplesEdge casesIntegrate

“I know I need a shopping cart. I have no idea how to implement a shopping cart.” The gap is not a missing tutorial; it is a missing method. Every stage below asks you to write before it shows you anything, because the code is the last step of a derivation, not the first thing to search for.

Which concept?

Grouped by exercise level; the level is how far the derivation goes, not how hard the code is.

Say what you need
beginner
intermediate
advanced

How much help?

Difficulty dial

Every stage's content is shown right after your attempt box.

Scheduler — twelve stages

I know I need to run tasks at a given time. I have no idea how to implement a scheduler.

0 / 12 stages attempted
I need XWhat is X?What must it remember?What can happen to it?What must always hold?ExamplesRepresent the stateWhich structure?Each operationPseudocodeImplement oneTest with examplesEdge casesIntegrate
stage 1 of 12

Define the concept

In one sentence, without any code: what is it? Then answer for yourself — does it have identity, who owns it, how long does it exist, should it survive a reload or a login?

Your attempt — write before you look

Scheduler = A set of tasks, each with a time at which it should run, that answers "which tasks are due now?" and hands them over exactly when their time has come.

Identity, ownership, lifetime
  • Does a scheduled task have identity? Yes. Two tasks scheduled for the same time are two tasks; each can be cancelled on its own, so each needs an id the caller keeps.
  • Who owns it? The caller that scheduled it — a user, a service, another task. The owner matters the moment cancel needs authorisation: only whoever scheduled it may cancel it.
  • How long does it exist? From schedule until it runs or is cancelled. What happens after — a record that it ran, a retry — is a different concept (a job log) and is not stored here in V0.
  • Should it survive reload? In V0 no: a restart forgets every pending task. Every real scheduler says yes, because "the reminder was lost when we deployed" is the first bug reported — that is V2.
  • Should it survive login? Tasks belong to the system, not to a session. A task scheduled by a user runs whether or not they are logged in; their login only decides who may cancel it.
The principle
If you do not know how to build the thing, make the thing smaller until you reach something you do know how to build. Go one primitive lower →
SIMPLIFIED

The catalog is one derivation, not the only one (impl §60). A different set of examples yields different rules; a different first requirement yields a different V1; a map instead of an array is not wrong, only an answer to a different question. Compare your derivation with the reference for the differences, then decide which ones were rules and which were style.