🔐 Encrypted Wish Lists

Some elves are worried that nosy siblings are reading the wish lists, so they started scrambling them with a Caesar cipher. Now Santa can't read them either! Decode the lists before the sleigh leaves.

🛠️ Elf Cipher Strip

Shift: 0
To encrypt, find a letter in the top row and write the gold letter under it. To decrypt, find the gold letter and read the letter above it.

How a Caesar cipher works

Every letter slides forward in the alphabet by the same amount, called the shift (or the key). With a shift of 3, A becomes D, B becomes E, and at the end it wraps around, so X becomes A. Julius Caesar is said to have used this to send military messages more than 2,000 years ago.

Try it: set the strip to shift 3 and encode the word SNOW. (You should get VQRZ.)

List 1The easy one

From: Elf Pip · Shift: 3

List 2A riddle for a key

From: Elf Juniper · Shift: the number of sides on a stop sign

List 3No key at all

From: Elf Thistle · Shift: ??? (top secret)
Codebreaker's trick, frequency analysis: In English, the most common letter by far is E. Count which letter shows up most in the scrambled message. It's probably an E in disguise. Then figure out the shift that turns E into that letter.

DebriefHow a computer breaks it

A Caesar cipher only has 25 possible keys. A computer can simply try every one of them, which is called a brute-force attack. Click to try all 25 on List 3:

Discuss:
  1. How long did the brute-force attack take? How long would it take you by hand?
  2. How did you know which of the 25 lines was the real message? (Could a computer tell, too?)
  3. The encryption that protects your phone and online banking uses keys with about 2128 possibilities, which is roughly 340 trillion trillion trillion. If a computer tried a trillion keys per second, about how long would it take?
  4. Frequency analysis only needed the message itself, not the key. What does that tell you about designing a good cipher?

Your turnSend a secret wish

Pick a secret shift, write your own wish, and trade the scrambled version with a partner. Don't tell them your key! Can they crack it?

Scrambled:

Cracking a partner's message? Paste it here and drag the shift on the Elf Cipher Strip until it makes sense:

⭐ BonusBuild a codebreaker with AI

Elf Bramble intercepted one more message, and nobody knows the shift. This time, don't crack it by hand. Get Google Gemini to help you write a Python program that cracks it for you.

Intercepted by: Elf Bramble · Shift: unknown
  1. Open gemini.google.com and sign in with your school Google account.
  2. Ask Gemini to write Python code that decodes a Caesar cipher by trying every possible shift. Paste the scrambled message into your prompt. Be specific: say what the program should do and what it should print.
  3. Run the code. You can use Gemini's run button if it shows one, or paste the code into Google Colab.
  4. Find the line that makes sense and type the decoded message below.
Stuck on your prompt? Try something like: "Write a short Python program for a beginner that decodes a Caesar cipher message by trying all 25 shifts and printing each result with its shift number. Here is the message: …"
Don't just trust the AI. Check it:
  1. Find the line of code that actually shifts a letter. Explain to a partner how it works.
  2. What does the code do with spaces? Did Gemini handle them correctly the first time?
  3. Did the code have any bugs, or did you need to ask Gemini to fix something? What did you change in your prompt?
Extra challenge: Ask Gemini to change the program so it picks the right answer by itself instead of printing all 25. (Hint: what do real English sentences have a lot of?) Does it work on Elf Thistle's message from List 3, too?

🕵️ Final challengeA real codebreaking job

Someone at the North Pole got smarter. This message doesn't use a shift. Every letter was swapped for a random different letter, so E might be G and T might be N. This is called a substitution cipher.

Why the Cipher Strip can't help: A Caesar cipher has 25 keys. A substitution cipher has about 403,000,000,000,000,000,000,000,000 (26 × 25 × 24 × … × 1). Even if a computer tried a billion keys every second, it would take more than 10 billion years to try them all. Brute force is off the table. You'll need patterns, code and your own brain.
Intercepted transmission · Key: unknown

Your mission

  1. Get the data. Ask Gemini to write Python code that counts how often each letter appears in the message, from most to least common. Then ask for code that lists the most common one-letter, two-letter and three-letter words. Run it in Gemini or Google Colab.
  2. Make smart guesses. The most common English letters are E, T, A, O, I and N. The most common three-letter word is THE. A one-letter word is almost always A or I.
  3. Test your guesses in the workbench below. Type the real letter under each scrambled letter and watch the message appear. Green letters are your guesses.
  4. Look for half-finished words. If you see TH_T or C_RISTMAS, you can fill in the missing letter. Keep going until it all makes sense.

Codebreaker's workbench

Each box shows a scrambled letter and how many times it appears. Type your guess for the real letter. A red box means you used the same guess twice.

Try this experiment: Paste the scrambled message into Gemini and just ask, "Decode this message." Then check its answer in the workbench. Does every scrambled letter always turn into the same real letter? AI chatbots sometimes give an answer that sounds right but doesn't actually match the code. They make up a believable message instead of solving it.
  1. Was Gemini's answer correct? How could you tell?
  2. Which worked better: asking AI for the answer, or asking AI to write code that helped you find it? Why?
  3. Real codebreakers at places like the NSA use computers to do the counting and testing. What part of the job still needs a human?
Expert level: Ask Gemini to write a Python program that solves substitution ciphers automatically, using "hill climbing" with English letter-pair frequencies. Can it crack the message without any help from you?