Mohammad Mahmoud Interactive lessons

Guess, then check.

Why guess first?

Your first guess is your intuition, and intuition is natural: it shows up whether you ask for it or not, and it is right more often than you would think. The trick is not to switch it off but to use it and then examine it. Say what you expect before you look, then see what actually happens. A right guess becomes something you can trust. A wrong guess shows you exactly where your picture of the problem bends — and that is worth more than being told the answer.

Four short lessons — logic, machine learning, running time and Turing machines — made entirely of exercises that work this way. You commit to an answer; then the page shows you what happens and why. Nothing is revealed before you have guessed.

Built by Mohammad Mahmoud, a mathematician (PhD, computability and logic) who teaches theory of computation, algorithms and data structures at the University of Toronto. Plain HTML, no accounts; progress stays in your browser.

Nothing is revealed until you commit — that is the rule on every page here.

The four lessons

Start anywhere: each lesson stands on its own. The numbers are a suggested order, not a requirement.

1Logic

Quantifier Gym

Sentences with “for all” and “there exists”. Learn why swapping their order changes the meaning, practise with small games and puzzles, then write a proof and let the page try to break it.

In real life: it is the difference between “every user has a password” and “one password works for every user”. Same words, different order — and one of them is a security hole.

7 modules57 checksabout 30 minOpen
2Machine learning

Nearest Neighbours

A computer that classifies a new point by looking at its nearest neighbours. Drag points around, change k, and watch how the decision changes.

In real life: it is the idea behind “people who bought this also bought…” — find the shoppers most like you and copy what they chose — and behind reading handwritten digits on a cheque or a postcode.

11 exercisesabout 15 minOpen
3Running time

Counting Steps

The running time of one computation is a number. The running time of a program is a function: how long it takes depending on the size of the input. Learn to count steps and compare programs.

In real life: it is why an app that feels instant with a hundred photos can crawl with a hundred thousand — and how engineers predict that before it happens.

11 exercisesabout 15 minOpen
4Turing machines

Mechanical Moves

The simplest possible computer: a tape, a head, and a short list of rules. Step through small programs one move at a time, then write one yourself.

In real life: everything your phone or laptop does, this machine can do too. That is how we know some problems no computer will ever solve — like telling in advance whether a program will finish.

6 exercisesabout 10 minOpen

If you only have five minutes

One exercise from each lesson, each a minute or two long.

  1. Play against a scepticYou claim something is true; an opponent picks the numbers that try to break it. If you can always answer, your claim holds.
  2. Where does the new point go?Drop a point among the coloured ones and guess which colour it gets. Then change k and watch the border move.
  3. Who wins, you or the input?Claim that one running time stays under another, lock in your numbers, and let a challenger pick the input size. Then switch sides and break a claim yourself.
  4. What does this machine compute?Three rules and a tape. Guess the formula, then run the machine and count what is left.