
An apprentice tile-maker discovers that there are exactly 17 ways to repeat a pattern.
The Apprentice
In 1370, in Granada, a girl named Zahra swept tiles for a living. Every morning she arrived before dawn at the workshop of Master Yusuf, the finest tile-maker in the Nasrid kingdom, and every morning her job was the same: sweep the dust, grind the pigments, carry the water, and — if she was lucky — watch the master work.
Master Yusuf made tiles for the Alhambra, the great palace on the hill. Its walls were covered in geometric patterns so intricate they seemed to breathe — stars that turned into flowers, flowers that turned into stars, shapes that repeated forever in every direction without a single gap or overlap.
At night, when the workshop was empty, Zahra would kneel on the floor and arrange broken tile pieces into designs. Triangles, squares, hexagons — she could make them fit together perfectly. But when she tried pentagons, they always left gaps.
"Why don't pentagons work?" she asked Master Yusuf one morning.
The old man smiled. "That is the first real question you have asked me."
The Secret of 360
Master Yusuf drew a point on paper. "For tiles to fit with no gaps, the angles at every corner must add to exactly 360 degrees."
He placed three hexagons around the point. Each corner is 120°. Three corners: 360°. "Perfect fit."
Four squares. Each corner is 90°. Four corners: 360°. "Perfect fit."
Six triangles. Each corner is 60°. Six corners: 360°. "Perfect fit."
Then he drew a pentagon. Each corner is 108°. Three pentagons: 324°. Not enough. Four: 432°. Too much. "There is no whole number of pentagons that adds to 360. This is mathematics, not effort."
The Four Magic Moves
Over the following weeks, Master Yusuf taught Zahra the four operations every pattern was built from.
Translation — sliding a tile in a straight line without turning it.
Rotation — spinning a tile around a fixed point.
Reflection — flipping a tile as in a mirror.
Glide reflection — slide forward, then flip. Like footprints in sand — left, right, left, right.
"Every repeating pattern in the Alhambra uses some combination of these four moves. There are no others."
Zahra practised until she could look at any wall and name the moves: "Translation along the horizontal. Rotation by 90° at that star. Reflection across that vertical line." The walls that had seemed magical now seemed like sentences in a language she was learning to read.
Exactly Seventeen
One evening, cataloguing patterns, Zahra noticed the number of truly different types seemed to stop growing. She kept finding the same types in different costumes.
"How many different pattern types are there?" she asked.
"Seventeen. Exactly seventeen. Not sixteen, not eighteen. There are exactly seventeen fundamentally different ways to repeat a pattern on a flat surface."
"How can you be sure?"
"Because the mathematics proves it. The angles, the rotations, the reflections — there are only so many ways they can combine."
Zahra spent the next month walking through every hall of the Alhambra, cataloguing tiles. And Master Yusuf was right. She found all seventeen types — every possible way to fill a plane with a repeating pattern.
"The builders discovered all seventeen centuries before mathematicians could prove it," said Master Yusuf. "They found them by intuition, by experiment, by beauty. The proof came later."
The Crystals Beneath
Years later, a scholar visited Zahra's workshop. He studied how atoms arrange themselves in crystals. He showed Zahra drawings of atomic arrangements, and she laughed.
"These are my wallpaper patterns," she said.
The scholar nodded. "The same seventeen symmetry groups that govern your tiles also govern crystals. The mathematics of beauty and the mathematics of nature are the same."
Zahra looked at her tiles, then at the crystal drawings. The same geometry — on palace walls and in the heart of a diamond.
The end.
Choose your level. Everyone starts with the story — the code gets deeper as you go.
Here is a taste of what Level 1 looks like for this lesson:
import matplotlib.pyplot as plt
import matplotlib.patches as patches
fig, ax = plt.subplots(figsize=(8, 8))
colors = ['#E8A87C', '#D5573B', '#41B3A3', '#C38D9E']
for row in range(8):
for col in range(8):
color = colors[(row + col) % 4]
sq = patches.Rectangle((col, row), 1, 1,
facecolor=color, edgecolor='white', lw=2)
ax.add_patch(sq)
ax.set_xlim(0, 8); ax.set_ylim(0, 8)
ax.set_aspect('equal')
ax.set_title('p4 Wallpaper Group — 4-fold rotation')
ax.axis('off')
plt.show() # Try changing the color rule!This is just the first of 6 coding exercises in Level 1. By Level 4, you will build: Build a Tessellation Pattern Generator.
By Level 4, enrolled students build: Build a Tessellation Pattern Generator
Free
Level 0: Listener
Stories, science concepts, diagrams, quizzes. No coding.
You are here
Level 0 is always free. Coding levels (1-4) are part of our 12-Month Curriculum.
The mathematical rules that govern repeating patterns — from palace walls to crystal lattices.
The big idea: "The Geometry of the Alhambra" teaches us about Symmetry, Tessellations & Group Theory — and you don't need to write a single line of code to understand it.
If your tiles are squares, you can cover a floor perfectly. Same with triangles or hexagons. But circles? Impossible. No matter how you arrange circles, curved gaps remain.
What about pentagons? Each interior angle is 108°. Three at a corner: 324° (36° gap). Four: 432° (overlap). No whole number of pentagons adds to 360°. You cannot tile a floor with regular pentagons.
This is the 360-degree rule: at every vertex, the angles must add to exactly 360°. Only three regular polygons satisfy this alone:
Check yourself: A regular octagon has 135° corners. Can it tile alone? No (135 × 2 = 270, 135 × 3 = 405). But mix octagons with squares: two octagons (270°) + one square (90°) = 360°. That is a semi-regular tessellation — the pattern on many bathroom floors.
Key idea: For tiles to cover a surface with no gaps, the angles at every vertex must total exactly 360°. Only equilateral triangles, squares, and regular hexagons can do this alone.
Every repeating pattern ever made is built from some combination of exactly four symmetry operations.
1. Translation — slide the tile in a straight line without rotating or flipping. Like a row of stamps. Every repeating pattern must include this.
2. Rotation — spin around a fixed point. A square tile rotated 90° looks the same. Triangles have 3-fold rotation (120°). Hexagons have 6-fold (60°).
3. Reflection — flip across a line, like a mirror image. Hold your right hand to a mirror — the reflection is a left hand.
4. Glide reflection — translate, then reflect. Think of footprints in sand: left, right, left, right. Each print is a shifted mirror image of the previous one.
These four are the only distance-preserving transformations of a flat surface. There is no fifth option. Mathematicians have proved this.
Key idea: Every repeating pattern uses exactly four possible operations: translation (slide), rotation (spin), reflection (flip), and glide reflection (slide + flip). No others exist.
Access all 130+ lessons, quizzes, interactive tools, and offline activities
If you combine the four operations in every possible way, how many fundamentally different repeating patterns can you make? The answer: **exactly 17**...
In 1891, Fedorov was not thinking about palace walls. He was thinking about **crystals**. Salt, diamond, quartz — all crystals are atoms arranged in r...