Exchanges and invariants

← Back to specs
Secondary 19 Rooms Invariants Modular arithmetic

Teaching objectives

You've just walked into a rather peculiar game room… In front of you are machines that convert one kind of object into another. How do you reach your goal? Is it always possible?

Across seven very different scenarios — coins, calculators, coffee cups, magic trading cards, chameleons, and savings — students learn to prove that certain outcomes are unreachable by appealing to modular arithmetic.

What you'll learn

Students discover that many "is it possible?" problems are solved by finding an invariant: something that every allowed operation preserves, which tells us whether the goal is reachable or not. Across 19 rooms in 7 progressive blocks, exploring and conjecturing always comes before the proof.

  • In the Coin exchange block (rooms 1–4) students apply exchange rules and discover that certain totals are impossible; room 4 introduces the idea of a Diophantine equation (coins worth 7 and 11 runs).
  • In the Calculator ×2/−3 and ×2/+3 blocks (rooms 5–9) students experiment with which values are reachable and which are not, using modular arithmetic to justify their reasoning.
  • In the Coffee and milk block (rooms 10–12) students reason about mixtures across three cups and detect the parity invariant that makes a certain exact distribution impossible.
  • In Hogsmeade (rooms 13–15) students exchange magic objects for trading cards and look for the maximum reachable total.
  • In Chameleons (rooms 16–17) students discover that the remainder modulo 3 of the differences between colour counts is the invariant that determines whether all chameleons can unify into one colour.
  • In Chip-firing (rooms 18–19) students distribute savings or "fire" boxes and recognise the same invariant pattern in a graph context.

Key mathematical ideas

  • An invariant is a quantity that stays the same after any allowed operation; if the starting state and the target state differ in that quantity, the target is unreachable.
  • Modular arithmetic (division remainders) is the standard tool for computing invariants in exchange problems.
  • The Diophantine equation ax + by = c has integer solutions if and only if gcd(a, b) divides c (applied in the 7-and-11 coins block).
  • In the chameleon problem the invariant is the difference in population counts modulo 3; unification is possible only if all three populations are congruent to each other.
  • Chip-firing (firing chips on a graph) always converges to the same final state regardless of the order of firings: another invariant, this time of the process itself.

Room-by-room contents

Room 1 · The change machine

An interactive change machine where each tap exchanges a 20 or 50 cent coin according to the rules 20 = 5+5+10 and 50 = 20+20+10. Introduces the concept of invariant through the total in cents.

Student tasks

  • Tap coins to exchange them according to the rules.
  • Get exactly 6 five-cent coins.

Room 2 · Exactly 14 coins

The rules change: now 50 → 10×5. Starting from two 50-cent and two 20-cent coins, the goal is to reach exactly 14 coins. First challenge with a concrete numerical target on the counter.

Student tasks

  • Plan which coins to exchange to reach the correct count.
  • Get exactly 14 coins in total.

Room 3 · Exactly 11 coins?

With the same rules as the previous room and the same starting configuration, the student tries to reach exactly 11 coins. The parity of the coin count is the invariant that makes it impossible.

Student tasks

  • Try to reach 11 coins and check whether it is possible.
  • Reflect on why the number 11 cannot be reached with those rules.

Room 4 · The strange kingdom of coins

In a kingdom with coins worth 7 and 11 runs, Psi owes 2 runs to Phi. By passing coins from one character to the other, the debt must be settled exactly. Introduces the Diophantine equation 7a − 11b = 2 in a concrete setting.

Student tasks

  • Tap coins to transfer them from one character to the other.
  • Make the difference between both balances equal 0 (debt settled).

Room 5 · Reach 21

A two-button calculator (×2 and −3) starting from 3. The student must find the sequence of button presses that reaches 21, exploring how modular arithmetic mod 3 acts as an invariant.

Student tasks

  • Press ×2 and −3 in the right order to reach 21.

Room 6 · Reach 39

Same ×2/−3 calculator, new target: 39. The student consolidates the strategy and notices that certain residues mod 3 are always reachable from 3.

Student tasks

  • Find the sequence of button presses to reach 39.

Room 7 · Does it reach 7?

Same ×2/−3 calculator. The target is 7, which is not reachable from 3 with those operations. The room invites the student to discover the invariant that prevents it.

Student tasks

  • Try to reach 7 and convince yourself it is impossible.
  • Look for the property of the number that makes it forever unreachable.

Room 8 · Reach 34

The operations change to ×2 and +3, starting from 1. The student explores a new invariant (mod 3 is not enough: now all values that are sums of powers of 2 are reachable). Challenge: reach 34.

Student tasks

  • Use ×2 and +3 from 1 to reach 34.

Room 9 · What about 15?

Same ×2/+3 calculator from 1. The target is 15, which is also unreachable. The student must discover the new invariant that blocks it.

Student tasks

  • Try to reach 15 and detect why it is impossible.
  • Compare this invariant with the one from the previous block.

Room 10 · Coffee for three — easy challenge

Three cups of 384 ml with different coffee-to-milk ratios (Ana: all coffee; Bea: half; Clara: all milk). The operation X↔Y transfers 1/3 of cup X to cup Y, which returns the same amount. First challenge with an easy target: Ana=225, Bea=168, Clara=183 ml of coffee in 4 steps or fewer.

Student tasks

  • Choose pairs of cups to swap and find the 4-step sequence.
  • Check that the total amount of coffee (576 ml) is always conserved.

Room 11 · Coffee for three — hard challenge

Same three-cup setup. New tighter target: Ana=204, Bea=189, Clara=183 ml of coffee. Requires more steps and careful thinking about which swaps preserve the invariant.

Student tasks

  • Find the sequence of swaps that achieves the requested distribution.

Room 12 · What about exactly 1/2?

Same setup. The student tries to give Ana exactly 1/2 coffee (192 ml). If unable, they must find out why that exact value is unreachable with the available swaps.

Student tasks

  • Try to reach Ana = 192 ml of coffee.
  • Reason about which invariant prevents reaching that exact value.

Room 13 · Hogsmeade — 10 cards

At a magical fair, Time-Turners (G), Sneakoscopes (Ch) and Remembralls (R) are exchanged according to fixed rules, earning 1 card per exchange. Starting with 4+4+4, the goal is at least 10 cards.

Student tasks

  • Apply successive exchanges to accumulate at least 10 cards.

Room 14 · 20 cards or more

Same exchange rules at Hogsmeade. The target rises to 20 cards, requiring a longer and more methodical sequence.

Student tasks

  • Plan the sequence of exchanges to reach 20 or more cards.

Room 15 · 27 cards?

Same fair and same rules. The student tries to reach 27 cards and, if unable, must discover the true maximum and why the invariant sets a ceiling.

Student tasks

  • Try to reach 27 cards.
  • Determine the real limit and identify the invariant that imposes it.

Room 16 · Chameleons — all the same colour

Three types of chameleons (Red, Yellow, Blue): when two of different colours meet, both take on the third colour. Starting from 3+3+3, the student tries to make all of them the same colour.

Student tasks

  • Select meetings between chameleons of different colours.
  • Get all 9 chameleons to be the same colour.

Room 17 · 5 red, 4 yellow, 3 blue

Same meeting rules for chameleons. Now starting from 5+4+3. The student tries to unify the colour and, if unable, discovers the modular invariant (differences mod 3) that prevents it.

Student tasks

  • Try to make all chameleons the same colour.
  • Reason about why this starting configuration does or does not allow it.

Room 18 · Equalise the savings

Four friends want to equalise their savings. The chip-firing rule: whoever has enough to give €1 to each friend distributes it all at once. The student taps the highlighted character (yellow) until everyone has the same amount.

Student tasks

  • Tap the ready friend each time it is their turn to distribute.
  • Observe how the process converges and the total is always conserved.

Room 19 · Exploding boxes

A row of boxes where the last one starts with all the points. A box with ≥2 points can explode: it loses 2 and its left neighbour gains 1. The process continues until no box has more than 1 point. The final distribution is always the same regardless of the order of explosions.

Student tasks

  • Explode boxes in different orders and compare the final state.
  • Connect the result to the chip-firing distributions from the previous room.

Rooms to project

The most striking ones to show and discuss in class.

Room 3 · Exactly 11 coins? — The "aha" moment of the coins block: impossibility is the hook for introducing the concept of invariant. Project it and debate why parity blocks certain targets.
Room 7 · Does it reach 7? — The ×2/−3 calculator is visually simple but the mod 3 invariant is not obvious; ideal for the class to discover it collectively before solving.
Room 16 · Chameleons — all the same colour — The chameleons are eye-catching and the colour-change dynamics are surprising: perfect to project and let students suggest meetings out loud.
Room 19 · Exploding boxes — Chip-firing in a row is visually spectacular and closes the lab by connecting all the invariants seen: project different explosion orders and verify that the final state is always the same.