Invent the idea behind the formula.
Each puzzle gives you a job, not a formula. Write any Python function you think works. Every run finds the first thing wrong with it, shows your answer next to the right one, and waits for your fix, until you’ve invented the idea yourself.
How a puzzle goes
You write any function
def typical(values): return values[0]
Each run finds what’s wrong, with your numbers
Complaint #1 · Order doesn’t matter
Shuffling the list changed your answer from 3 to 9.
| 9 | 6 | 3 |
Fix it until nothing’s left
You invented it.
Part 1
One number that stands for a whole list, and why there’s more than one right way to pick it.
One number that stands for a whole list. Lots of choices work until four friends split a bill.
A billionaire walks into a bar. Your fair share now says everyone is rich.
Homework, midterm, final: some count more than others. One grade has to stand for all of them.
+50% one year, −50% the next. Is that an average year of no change? Your money says otherwise.
60 km/h there, 30 km/h back. The average speed isn’t 45, and the clock can prove it.
Values arrive one at a time and you can’t keep them. Keep their average anyway.
Part 2
How far two points are, how spread out a list is, how much to trust an average, and how to combine readings you trust differently.
How far apart are two points? Walking the streets and flying straight give different answers.
Biggest minus smallest seems fine, until it can’t tell two very different classes apart.
Ana beat her class average by 10 points, Ben by 5. Ben still did better.
Weigh a bag four times and average. The average wobbles less, but not four times less.
One broken sensor drags the average and the spread toward itself, and hides.
A lab thermometer says 20°, a cheap one says 25°. Averaging them makes the good one worse.
Part 3
Scores for how alike two things are: tastes and movies, searches and documents, fruit, words.
How much will you like a movie, given what you like and what’s in it?
Rank documents for a search. Copy-paste spam and long rambling documents keep winning.
How far does an arrow reach in a given direction? Measure its shadow.
Hours studied and test scores: do they rise together? Adding up x × y says yes to everything.
Name a new fruit after the known fruit it’s closest to. Closest by size, by redness, or both?
Match people by what they’re into. Someone who likes everything shouldn’t match everyone.
A model only reads numbers. Calling the colors 0, 1 and 2 quietly tells it green sits between red and blue.
Which words say what a document is about? “the” shows up the most and means the least.
A page that says “python” 400 times isn’t 400 times more about Python. How much does the tenth mention add?
Words as points on a map: man is to king as woman is to what?
Part 4
What a transform does to area, the one direction in a cloud that matters most, where to put a shop, and how much room a boundary leaves.
A 2×2 matrix moves every point of the plane. How many times bigger does a shape get?
Squash a map of towns onto one straight road. Which way should it run so the towns stay as spread out as possible?
Every home orders from its nearest pizza shop. Move each shop to serve its own customers best.
Two fences both keep the sheep from the goats. One brushes past a sheep. Which is safer, and by how much?
Part 5
Turning any scores, even negative or enormous ones, into chances that add up to 100%, then picking from them.
A model scores each answer. Turn any scores, even negative ones, into chances that add up to 100%.
A spam filter scores an email. Turn one score, any size, into the chance it’s spam.
A model picks the next word. One knob decides whether it always takes its favourite or spreads its bets.
Turn scores into chances when the scores are in the thousands. e¹⁰⁰⁰ doesn’t fit in a float.
A computer only rolls fair numbers from 0 to 1. Turn one into a roll of a loaded die.
A model picks its next word by chance. Drop the junk words first, but keep the variety it really has.
Part 6
Fair prices, rare diseases, combining clues, and one number for how surprised you should be.
A scratch card pays $100 one time in ten. What should a ticket cost?
A test that’s right 99% of the time says positive. How worried should you be?
Two clues each say 80% spam. Together they should say more, but how much more?
A rookie makes their first 2 free throws. Are they a 100% shooter?
One number for how uncertain you are before a coin lands, a die rolls or a model picks the next word.
Splitting off one spam email leaves a perfectly pure side. Did that question really help?
You set up your questions for a 99-to-1 world. It turned out to be 50/50.
A forecaster said 20% rain, and it rained. How much should that cost them?
Score a sentence by how likely it is. Multiply 2,000 word chances and the computer runs out of zeros.
A language model guessed each next word. One number for how lost it was: “like choosing among k words”.
A model that has never seen a letter pair calls it impossible, then meets it in the very next sentence.
Part 7
Telling luck from a real effect, and scoring a model honestly.
A coin lands heads 15 times out of 20. Is it rigged, or could a fair coin do that?
Test 20 jelly bean colours for a link to acne and one will look guilty by pure luck.
A model predicts a lemonade stand’s sales. Is it any better than always saying the average?
Averaging precision and recall seems fair, until a filter that flags every email scores 50%.
A test scores patients from low to high. How good is the ranking, before anyone picks a cutoff?
A model wrote 10 answers and 3 are right. Check 2 at random: how likely is at least one right?
Part 8
Measuring how wrong a model is, then walking that number down: steadier, faster, and without forgetting.
Score a weather forecast. Why do models square their errors instead of just adding them up?
Lost on a foggy hill, you can only feel the slope under your feet. Which way, and how far, is the next step?
Draw the best line through a cloud of points. Every point has its own idea of the slope; who gets the final say?
Two noisy points and a confident slope. How do you build in a little doubt?
A noisy sensor jumps around. Keep one smoothed value that follows it calmly, without storing the history.
A careful walker stops the moment the ground goes flat. A rolling ball doesn’t. Give your downhill step some momentum.
In a long, narrow valley the walls are 100× steeper than the floor. One step size bounces off the walls or crawls along the floor.
Your GPU fits 8 photos at a time, but you want the step a batch of 32 would take. Four small batches should add up to one big one.
A network learns a new task and forgets the old one. Charge it for moving the weights the old task needs.
Part 9
Why stacked layers need a bend, who gets the blame, and how a deep net keeps its signal alive.
The output came out wrong. Nudge the input and follow the nudge through every stage to see how much it’s to blame.
Stack two layers of straight lines and you get… a straight line. Find the bend that lets a network draw a V.
A deep network starts with random weights. Pick their size wrong and the signal dies out or blows up in 20 layers.
Stack 50 layers that barely know anything yet, and the signal fades to nothing before it reaches the end.
One loud example in a batch, and every other example’s numbers shift. Rescale so each example stands on its own.
In training, units of a network randomly skip work. The next layer shouldn’t be able to tell, on average.
A target of exactly 100% can only be reached with an infinite score. Teach a classifier to keep a little doubt.
Blur a row of pixels by mixing each one with its neighbours. A photo filter, and the first step of every image model.
Stack small windows on a row of pixels. How much of the picture can one output at the top see?
Part 10
How a model decides which words to listen to, and the tricks that make language models work.
A tokenizer starts with single letters and invents new symbols by gluing neighbours. Which pair should it glue first?
In “the cat sat on the mat because it was tired”, which word does “it” mean?
Now “it” knows who to listen to. What does it actually hear?
A model writing word by word can’t listen to words it hasn’t written yet.
Attention reads a sentence as a bag of words, so “dog bites man” and “man bites dog” look the same. Tag each word with where it is.
Tag each word with where it sits, so attention can tell how far apart two words are but not where they are.
Scores arrive one at a time and you can’t keep them. Keep what softmax needs anyway, without overflowing.
Take the likeliest word, then the likeliest next one. The likeliest sentence can still slip past.
Teach a model that two crops of the same photo belong together, using nothing but the rest of the batch as strangers.
Fine-tuning nudged a huge grid of weights. Store the nudge in a tiny fraction of the numbers.
Part 11
Rewards that arrive over time, trying the unknown, and learning from what people prefer.
Rewards spread over the coming steps. One later is worth a bit less than one now. What is the whole list worth today?
Learn what a position is worth from the very next step, instead of waiting for the game to end.
Machine A has paid 0.6 a play over 100 plays, B 0.5 over just 2. Which do you play next?
You surveyed the people who were easy to reach, but you want the average of a different crowd.
A reward model scores two answers −1 and −3. How often will people pick the first?
A model answers one question 8 times and a grader scores each. Which answers should training push up?
Part 12
Learning on a network of friends, turning pictures into static, and making a big model fast to serve.
Everyone updates their opinion from their friends’. How much should their own count?
Bury a picture in noise one step at a time, without it shrinking on the way.
A chip does math and fetches numbers at the same time. Which one decides how long a step takes?
Squeeze every weight into one byte. Works fine, until a single huge weight wipes out all the small ones.
A chatbot writes one word at a time. Does it have to reread everything it wrote before each new word?