Source: https://mokxi.com/learn/path/coding-puzzles-python
Updated: 2026-11-20

All paths

# Coding puzzles with Python

Crack the classic programming puzzles as a space station crew, from FizzBuzz and primes to binary search, tic-tac-toe and calendar math, and finish with a Sudoku referee that lights up on the Pi.

Raspberry Pi 4 Model B Free 7 lessons 5 h 4 chapters 1,925 XP Coding · Beginner +100 XP

0 of 7 done

Start the course free FizzBuzz and friends Lesson plan for teachers

What you will build

## 3 projects, built step by step

7 lessons in 4 chapters, about 5 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Primes

Decode a signal made of primes: test a number by trial division, stop at the square root, cross out multiples with the Sieve of Eratosthenes to find 1229 primes at once, hunt twin primes, split numbers into prime factors, and build a prime detector with two LEDs.
Open it in the simulator

Chapter 2 project

### Guessing strategy

Guess a secret number and discover binary search: play by halving the range, write a robot that halves for you, measure its worst case and average over every secret, see why a million numbers take only 20 guesses, and use the same idea to find the square root of 2.
Open it in the simulator

Chapter 3 project

### Calendar math

Date puzzles from mission control: fix a leap year rule that fails on 1900, count the day of the year, work out the weekday of the Moon landing by counting days from 1900, check your answer against datetime, and find the next Friday the 13th.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Number puzzles

Remainders, rules as data, and the primes hiding in a signal.

Open 190 XP

### FizzBuzz and friends

The most famous warm-up puzzle in programming: find the bug in a first FizzBuzz, fix the order of the tests, count a hundred answers, turn the rules into data so a new rule is one line, meet the hailstone numbers, and play it on two LEDs.

0 of 6 steps

Start What is in it

Project Locked 380 XP

### Primes

Decode a signal made of primes: test a number by trial division, stop at the square root, cross out multiples with the Sieve of Eratosthenes to find 1229 primes at once, hunt twin primes, split numbers into prime factors, and build a prime detector with two LEDs.

0 of 6 steps

5 questions, graded as you go.

Chapter 2

## Words and search

Palindromes from both ends, and the halving trick behind binary search.

Locked 190 XP

### Palindromes

Words that read the same both ways: reverse a string without the slice MicroPython lacks, clean phrases down to their letters, check from both ends with two pointers, find palindrome years and count palindrome numbers, find the longest one hidden in a string, and run a docking computer with two LEDs.

0 of 6 steps

Project Locked 380 XP

### Guessing strategy

Guess a secret number and discover binary search: play by halving the range, write a robot that halves for you, measure its worst case and average over every secret, see why a million numbers take only 20 guesses, and use the same idea to find the square root of 2.

0 of 6 steps

5 questions, graded as you go.

Chapter 3

## Grids and dates

A board in a list of lists, a computer that blocks, and days counted from 1900.

Locked 190 XP

### Grids and tic-tac-toe

Store a grid as a list of lists: draw it, read cells by row and column, list all 8 winning lines to find a winner, play two players over the Serial Monitor with every bad move answered, light the winner on the LEDs, and play a computer that wins when it can and blocks when it must.

0 of 6 steps

Project Locked 380 XP

### Calendar math

Date puzzles from mission control: fix a leap year rule that fails on 1900, count the day of the year, work out the weekday of the Moon landing by counting days from 1900, check your answer against datetime, and find the next Friday the 13th.

0 of 6 steps

5 questions, graded as you go.

Chapter 4

## Boss

Every idea in one referee: the Sudoku checker.

Locked 215 XP

### Boss: a Sudoku checker

The finale puzzle: check a Sudoku grid. Draw it with box lines, check rows, columns and 3 x 3 boxes with one shared test, report exactly which digit repeats where, check a half-solved puzzle with zeros for blanks and light the answer, then take typed moves and judge each one.

0 of 7 steps

4 questions, graded as you go.

Syllabus

## Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Number puzzles

- FizzBuzz and friends The most famous warm-up puzzle in programming: find the bug in a first FizzBuzz, fix the order of the tests, count a hundred answers, turn the rules into data so a new rule is one line, meet the hailstone numbers, and play it on two LEDs.
- Primes Decode a signal made of primes: test a number by trial division, stop at the square root, cross out multiples with the Sieve of Eratosthenes to find 1229 primes at once, hunt twin primes, split numbers into prime factors, and build a prime detector with two LEDs.

Chapter 2

### Words and search

- Palindromes Words that read the same both ways: reverse a string without the slice MicroPython lacks, clean phrases down to their letters, check from both ends with two pointers, find palindrome years and count palindrome numbers, find the longest one hidden in a string, and run a docking computer with two LEDs.
- Guessing strategy Guess a secret number and discover binary search: play by halving the range, write a robot that halves for you, measure its worst case and average over every secret, see why a million numbers take only 20 guesses, and use the same idea to find the square root of 2.

Chapter 3

### Grids and dates

- Grids and tic-tac-toe Store a grid as a list of lists: draw it, read cells by row and column, list all 8 winning lines to find a winner, play two players over the Serial Monitor with every bad move answered, light the winner on the LEDs, and play a computer that wins when it can and blocks when it must.
- Calendar math Date puzzles from mission control: fix a leap year rule that fails on 1900, count the day of the year, work out the weekday of the Moon landing by counting days from 1900, check your answer against datetime, and find the next Friday the 13th.

Chapter 4

### Boss

- Boss: a Sudoku checker The finale puzzle: check a Sudoku grid. Draw it with box lines, check rows, columns and 3 x 3 boxes with one shared test, report exactly which digit repeats where, check a half-solved puzzle with zeros for blanks and light the answer, then take typed moves and judge each one.

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Coding puzzles with Python

Is Coding puzzles with Python free?

Yes. All 7 lessons of Coding puzzles with Python are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Raspberry Pi 4 Model B?

No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Coding puzzles with Python take?

About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Primes, Guessing strategy and Calendar math.

Where do I start?

With "FizzBuzz and friends", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
