March 10, 2007

Levers, Dials, and Mystic Math

Solving a computer game's puzzles can lead to adventure—and mathematical discovery.

Near the beginning of the game Myst, a player encounters a contraption that includes three levers and a tower of three dials, each one reading 3. Manipulating the levers reveals that each of the three numbers is one face of a three-sided block. Rotating a block unveils the other faces, numbered 1 and 2.

Let's label the levers A, B, and C. With a little experimentation, you soon discover that pulling lever A leaves the top block alone and rotates the middle and bottom blocks to show the next face. So, if you start with faces 1, 2, 3 (from top to bottom), the new configuration after pulling lever A would be 1, 3, 1.

Pulling lever B leaves the bottom dial alone and rotates the top two dials. Lever C simply resets the blocks to their original 3, 3, 3 configuration.

If you've been paying attention to other clues in the game, you realize that your task is use the levers to rotate the blocks until they read 2, 2, 1 instead of 3, 3, 3.

To figure out how to accomplish this task most efficiently, it helps to delve into the realm of modular arithmetic, groups, and linear algebra.

As mathematician and self-described "gaming geek" Jessica K. Sklar of Pacific Lutheran University in Tacoma puts it, the puzzle's numbers can be regarded as integers modulo 3 (0, 1, 2), where a face's 3 is identified with 0 in the set Z3. With three blocks, you have a set in which each element is a possible configuration of the blocks. And the contraption's levers can be regarded as actions on the group of these elements.

Sklar describes her analysis of the Myst puzzle (and several more puzzles from other games) in the December 2006 Mathematics Magazine.

So, starting with the element (0, 0, 0), you want to pull each of levers A and B a particular number of times to get the element (2, 2, 1). In effect, you're interested in writing (2, 2, 1) as a linear combination: (2, 2, 1) = a(0, 1, 1) + b(1, 1, 0), where a and b are the number of pulls required for each respective lever.

But there's no solution for a and b to the resulting system of congruences.

To solve the puzzle, you need an additional trick. It turns out that holding down lever A or B a little longer after the initial pull increments the middle number. So you're actually looking for (2, 2, 1) = a(0, 1, 1) + b(1, 1, 0) + c(0, 1, 0), where c represents the number of extra "beats" lever A or B must be held down.

Now, the system of congruences has a solution: a = 1, b = 2, c = 2. You solve the puzzle by pulling lever A once, lever B twice, and holding lever B down after its second pull just long enough to add (0, 1, 0) twice.

"And voilá, we hear a grinding noise and the gear at the bottom of the contraption opens," Sklar writes. "Moreover, we have now gained access to a book that will allow us to travel a different world. Nice, huh?"

"One of the most beautiful things about computer games," she adds, "is that they allow [us] to travel to worlds to which we can't physically go in real life: including mathematical worlds."


Sklar, J.K. 2006. Dials and levers and glyphs, oh my! Linear algebra solutions to computer game puzzles. Mathematics Magazine 79(December):360-361. Abstract.

Jessica Sklar's website is at

You can learn more about Myst at and

No comments: