A spaced review schedule in 15 lines of code
If you learn something once and never look at it again, most of it fades. If you look at it again just as it starts to fade, it lasts longer. Spaced repetition automates that second option.
You don’t need a research-grade algorithm to get most of the benefit. A ladder works well: each successful review moves an item one rung up, so the next gap is longer. A failed review moves it back down.
The ladder
const GAPS_DAYS = [1, 3, 7, 16, 35, 75, 150];
interface Item {
stage: number; // index into GAPS_DAYS
dueAt: number; // timestamp in ms
}
const DAY = 24 * 60 * 60 * 1000;
function review(item: Item, passed: boolean, now: number): Item {
const stage = passed
? Math.min(item.stage + 1, GAPS_DAYS.length)
: Math.max(item.stage - 1, 0);
const retired = stage >= GAPS_DAYS.length;
return { stage, dueAt: retired ? Infinity : now + GAPS_DAYS[stage] * DAY };
}
That’s the whole algorithm. A new item starts at stage 0, so its first review is after one day. Pass, and the next is in 3 days, then 7, 16, 35, 75 and 150. After passing the last rung the item is retired: you know it.
Why growing gaps?
Each time you recall something successfully, the memory lasts longer before it fades. So the gap that was right at day one is too short at day thirty. Growing gaps keep each review in the sweet spot: late enough to be effortful, early enough to succeed.
Why move down on a miss?
If you fail, the memory was weaker than the schedule assumed. Dropping one rung brings the next review sooner without throwing away all your progress. Dropping to zero feels punishing and wastes reviews on things you mostly know.
What this ladder doesn’t do
Fancier schedulers estimate a separate difficulty for each item and adjust gaps continuously. That can be more efficient, but it needs more data and is harder to reason about. A fixed ladder is predictable: you know roughly when things come back, and it’s easy to build into a habit.
Practical tips
- Review a lesson, not a card. Grouping several questions from one topic is faster than scheduling each separately, and it tests the idea from a few angles.
- Keep sessions small. A handful of due items takes a few minutes. Show a cap so a backlog never feels like a wall.
- Mix easy and hard. Quick predict-and-choose questions make better reviews than long coding tasks.
Paren uses exactly this ladder for finished lessons, so reviews arrive without you tracking anything.
Never schedule a review by hand
Finish a lesson and Paren brings it back at the right time.
Start free