The forgetting curve looks simple until you have to schedule the next review, handle a guessed answer, and not treat a late typo like a real miss. I ran into all three while building the review scheduler in Quiztr, the study app I work on for iPhone. What follows is a small, working version of that idea, and the cases that made the tidy version fall apart.

What the curve actually says

Hermann Ebbinghaus described the shape of forgetting in the 1880s: you lose a memory quickly at first, then more slowly. The useful design implication is narrower than the diagrams make it look. Review an item too soon and you waste a session confirming something that was never in danger. Wait until it is gone, and you are learning it again, not reviewing it. The aim is to come back while the memory is still there, just as it is getting hard to reach.

Spaced repetition is the practical response: after a successful recall, wait longer before the next one; after a miss, come back sooner. SuperMemo 2, from the late 1980s, is the algorithm a lot of later software still starts from, including a modified form in Anki. The happy path fits in a paragraph. Implementing it, then living with real answers from real people, is where it gets awkward.

I wanted a scheduler I could read in one sitting, in Swift, that still behaved like SM-2 on that happy path. The version below is inspired by SM-2, not a line-for-line port. I will say where I simplified, and why.

A small scheduler

A card only needs a few pieces of state: how long to wait, how easy the card has been, how many successful reviews it has in a row, and when it is due.

import Foundation enum Grade { /// No real recall. case again /// Recalled, but it was a struggle — or a guess you wouldn't trust. case hard /// Recalled cleanly. case good /// Recalled immediately, with no hesitation. case easy } struct Card { /// Days until the next review. var intervalDays: Double = 0 /// How strongly the interval grows after a success. SM-2 calls this the E-Factor. var ease: Double = 2.5 /// Consecutive successful reviews. A miss sets this back to zero. var repetitions: Int = 0 var due: Date = Date() static let minimumEase = 1.3 mutating func review(_ grade: Grade, on date: Date = Date()) { switch grade { case .again: // SM-2 restarts the interval sequence and leaves ease alone. repetitions = 0 intervalDays = 1 case .hard, .good, .easy: repetitions += 1 ease = nextEase(after: grade) intervalDays = nextInterval(after: grade) } let wholeDays = max(1, Int(intervalDays.rounded())) due = Calendar.current.date( byAdding: .day, value: wholeDays, to: date ) ?? date } private func nextEase(after grade: Grade) -> Double { let delta: Double switch grade { case .again: delta = 0 case .hard: delta = -0.15 case .good: delta = 0 case .easy: delta = 0.15 } return max(Card.minimumEase, ease + delta) } private func nextInterval(after grade: Grade) -> Double { switch grade { case .again: return 1 case .hard: // A small step forward, not the full ease-based jump. let previous = max(intervalDays, 1) return previous * 1.2 case .good, .easy: let base: Double switch repetitions { case 1: base = 1 case 2: base = 6 default: base = intervalDays * ease } return grade == .easy ? base * 1.3 : base } } } 

A short walkthrough of the happy path, always reviewing on the day the card is due:

var card = Card() card.review(.good) // first success: 1 day card.review(.good, on: card.due) // second: 6 days card.review(.good, on: card.due) // third: 6 * 2.5 = 15 days card.review(.again, on: card.due) // miss: back to 1 day, ease unchanged 

Most of the SM-2 skeleton is still here. Ease starts at 2.5 and never falls below 1.3. The first successful review is due in a day, the second in six, and later ones multiply the previous interval by ease. A miss restarts that sequence and does not touch ease, which is what the original algorithm does: one bad review should not permanently punish a card that has been easy for months.

I changed three things on purpose.

First, I collapsed SM-2's 0–5 quality scale into four grades. In a real session I do not want to ask someone to distinguish a 2 from a 3. I want to ask: did you miss it, barely get it, get it, or was it too easy? The "hard" grade is also how a guessed answer can enter the scheduler without pretending it was a clean recall.

Second, "hard" and "easy" also change the next interval, not only ease. That is a later-app habit, not original SM-2, which mostly used the quality score to nudge the E-Factor. If you barely remembered a card, I do not want the full ease-based jump. A hard review takes a small step forward from the current interval, 1.2 times, instead of leaping ahead as if the recall had been solid. An easy review uses the normal growth, then adds a modest bonus.

Third, I schedule in calendar days, not elapsed hours. Adding 24 hours to a review at 11pm makes the card due at 11pm tomorrow, which is a miserable way to miss a morning study habit. Adding one calendar day, then letting the session queue collect everything due on that date, matches how people actually sit down to study.

The code is short enough to be honest about what it cannot see. That list is longer than the struct.

The messy cases

First-time cards

A new card has no history. The first "good" might mean "I just read this on the previous screen." SM-2 still only grants a one-day interval, and that is why I kept the first two steps conservative. I would not graduate a brand-new card to a week because the first answer felt easy. There is no evidence yet, only a first impression.

Lucky guesses

A correct answer can be a coin flip, especially on a yes/no prompt, or when the wording of the question gives the answer away. The grade is the escape hatch: if you know you guessed, you can mark it hard or again. The awkward part is that people do not reliably admit a guess, and a binary auto-grader cannot see confidence. That is why I would rather collect a grade than infer everything from a string match.

Skipped days and overdue reviews

The scheduler above does not look at how late you are. If a card was due two weeks ago and you get it right today, that success means something different from a success on the morning it came due. You can read it as stronger memory — it survived a longer gap — or as a fluke. I have gone back and forth. Ignoring lateness is the honest admission that this tiny model does not have a good answer. A production scheduler should at least record the delay and avoid treating a very late success as proof that the next interval can jump by the same factor.

Cramming before an exam

Spaced repetition is built for memory that should still be there in a month. It is the wrong tool, used alone, the week of an exam. If a test is on Thursday, you may need to see material the scheduler would happily hide until next week. I treat that as an override: a temporary queue of "I need this now," not as a reason to smash every interval down to one day and wreck the long-term schedule. Cramming and maintenance are different jobs. The algorithm should not pretend to be both.

Typos versus real misses

This is the case that made me most suspicious of feeding raw correctness into review(_:). If the prompt is a short written answer and someone types a letter late, that is not a forgotten fact. Resetting repetitions to zero and putting the card back on a one-day interval is a harsh response to a fumble. The opposite bug is worse in a different way: if you auto-accept anything close, you can let a near-neighbor slip through — "mitosis" for "meiosis" — and never find the gap.

So I stopped letting the matcher call review by itself. Matching can suggest a grade; the session still needs a way to say "I was close" or "that was a typo." The scheduler only sees the grade. That split sounds small. It is the difference between an algorithm and a product.

A correct answer is not the same as remembering

Even a clean, typo-free "good" is only a signal. It is not a proof.

You can recognize an answer you could not have produced. You can produce an answer you saw thirty seconds ago, when the card was created, or when you missed it and flipped it over. You can feel fluent because the wording is familiar, not because the idea is. The first successful review, especially, is almost always mixed up with short-term leftovers.

That is why I like treating the first success more conservatively than the fifth, and why an immediate retry after a miss should not count as a new successful repetition. You did not recover the memory from a long gap. You recovered it from the screen in front of you. In the small scheduler above, a miss already resets repetitions, so the next success goes back to a one-day interval. That is the right bias. What the snippet does not do is prevent you from showing the same card again two minutes later and recording that as the one-day graduation. That policy lives outside the struct, in how you build the session queue. I would rather keep it out of Card than hide a session rule inside the interval math.

What I'd still change

I would not ship this struct unchanged.

It has no memory of lateness, as I said. It also treats every card as if one ease number can describe it, which is a rough fit for a fact you either know or you don't, and a worse fit for something you partly understand. It rounds to whole days, so a new card and a struggling card can bunch up tomorrow morning in a way that feels arbitrary. And SM-2 is old. Newer schedulers, such as FSRS, try to estimate how fast a particular memory is fading instead of growing an interval with a single multiplier. I have not swapped this code out for one of those, and I am not going to recommend a switch I have not done.

The changes I would make first are more boring than a new algorithm. Record whether a review was late, and do not let a very late success stretch the next interval as if the last interval had been planned that way. Keep typo handling and grading as two steps. Do not let a same-session retry graduate a card. Think in the user's calendar, including what "due tomorrow" means if they study late at night.

The forgetting curve is still a good explanation. It just is not a specification. The specification starts when someone types a near-miss at 11:40pm, two days late, and you have to decide what tomorrow looks like.

I drafted this post with help from an AI writing assistant and edited it myself.