Math Games

From Keyfobs to Ringtones

Ed Pegg Jr., October 3, 2005

Did anyone figure out the rule behind the key fob in the September 30th episode of the hit CBS show Numb3rs? All the clues you need are there (just pay close attention), so here's a chance to go and rewatch the episode. If you give up, you can come back and read the full explanation.

Welcome back. Charlie Eppes and Amita Ramanujan, characters from Numb3rs, are pondering a code. What does it mean? One of the delights in Numb3rs is that there is deep mathematics behind every show. In this episode, signals from a remote-entry key fob have been captured via a Kitt Peak-bound listening device made by character Larry Fleinhardt. Every time the keyfob button is pressed, the captured code changes. (This prevents nefarious types from recording a signal, then replaying it to open a car.)

Here is a cleaner version of the full codes, which you could get by watching the show (and fixing a minor transcription error).

23e2c4398e955abb ba62852a28800a06
23e9a20a4cb733d0 fa4a83f202a08a04
23f07fdb0ad90ce5 3aa10a2a30a042a3
23f75dabc8fae5fa 3a82aaa1ae902210
23fe3b7c871cbf0f baa6a60ac0029a0a
2405194d453e9824 c11fc0c2ff24a3c1

I've added a space within each 32 byte signal for clarity. Notice that hexadecimal difference between numbers in the first half always equal 6ddd0be21d915, mod 2^64 -- or 1932738473089301. The car expects a signal with a first half that matches the previous entry plus 1932738473089301 n, where 0<n<50. The second half of the code is based on the first half in some mysterious way. Changing the hexadecimal numbers to pairs of colored pixels will help to show the pattern. There are four different colors -- white, light grey, dark grey, black. Note that hexadecimal "2" in base 4 is "02", or {white (0), dark grey (2)}.

For any given three pixel set on top (such as white, dark grey, white), the same pixel (black) will always show up underneath. The car is thus looking for a correct application of a particular rule, in this case a 1-dimensional cellular automaton (as mentioned by Amita in the show). The fob sequence on the blackboard can be replicated with a short piece of Mathematica code.

With[{start = IntegerDigits[2583912149075329446 + 1932738473089301 n, 4, 32]}, Table[ BaseForm[ FromDigits[ Flatten[{start, PadLeft[ Last[ CellularAutomaton[ {600116, {4, 1}}, start, 1]],32]} ], 4], 16], {n, 1, 6}]]

It turns out this particular key fob is based on a 4-color totalistic cellular automaton with rule 600116. Here is a picture of what that rule does if you let it run for a few hundred steps from a random initial condition.

Cellular automata are also the key to the recently launched WolframTones have been covered at Business Week, Dr. Dobb's Journal, Nature, Science, the New York Times, ABC News, and even here at in Ivars Peterson's MathTrek. I'm behind the times, but I was waiting for Numb3rs to air.

As an example of how WolframTones works, consider an elementary cellular automaton, illustrated below. Take a slice of it, and lay it on its side.

Slice of Rule 30 Used for WolframTones Score Rule 30 Slice Tipped on Its Side

WolframTones uses various Mathematica algorithms to create music from these cellular automaton patterns. In its simplest form, this works by taking every block of contiguous black cells at a certain height and mapping it to a single note played by the same instrument. The result for elementary cellular automaton Rule 30, starting from a single black cell, is shown below, transcribed in the Scriabin musical scale and using a grand piano.

Click on the image at left to listen to the WolframTones version of this cellular automaton.

The above melody, in traditional music notation, takes on the more familiar form illustrated below.

The initial launch of WolframTones allows exploration of 16 different cellular automaton systems, with billions of possible rules for all but the simplest rules systems. WolframTones supports more than 300 musical scales, in excess of a hundred instruments, and thousand of different style combinations. Although everything starts from a single underlying cellular automaton pattern, different instruments can be set up to pick off different aspects of the pattern--say to correspond to a melodic line or a bass track. WolframTones also supports a number of algorithms for deriving percussion from cellular automaton patterns.

Clicking a single button at the site prompts Mathematica to evaluate dozens of rules before selecting the rule exhibiting the best class 3 or class 4 behavior, as described in Stephen Wolfram's book A New Kind of Science. So upon visiting the site, you can click the "Start Now" button to obtain an interesting piece of algorithmically-generated music that has never been heard before.

Click on the image at left to listen to the WolframTones version of this cellular automaton.

If it's not interesting enough, click on the "Random Style" button again. Alternately, choose one of the fifteen music styles, and something vaguely resembling that genre will get generated. If what you've found is close to something you like, you can modify the instruments, the musical scale, the initial conditions, the rule, or the tempo. With enough time, you could give a distinct WolframTones composition to every atom in the universe (many times more tunes than I-tunes).

More usefully, you can download the music as a ringtone to just about any cellular phone. You can also save anything you've generated in your own MyTones page (here's a link to a MyTones page for this column), and send the address to friends. If that's still not enough, check back again soon, since many possibilities are being considered for the future.

Yesterday, I demoed WolframTones to dozens of people at the Wall-to-Wall Guitar Festival. Kids especially seem to like the simplicity of it -- clicking on a single button allows them to create their own music. They were laughing as they created some really good music that even their parents liked. One kid went against the grain, and laughed as his parents and me reacted to a particularly horrible piece (with algorithmic music, it sometimes happens). Here's a piece that I saved during one of the demos:

Click on the image at left to listen to the WolframTones version of this cellular automaton.

It's no surprise that a company founded in Champaign-Urbana is launching a computer music service. In 1957, Lejaren Hiller programmed a UNIVAC to compose the Illiac Suite for String Quartet (mp3, picture1, picture2), the first piece of computer generated music, thus marking Champaign-Urbana as the birthplace of the genre. The most famous singing computer also came from Urbana:

HAL: Good afternoon, gentlemen. I am a HAL 9000 computer. I became operational at the H.A.L. plant in Urbana, Illinois on the 12th of January 1992. My instructor was Mr. Langley, and he taught me to sing a song. If you'd like to hear it I can sing it for you.
Dave Bowman: Yes, I'd like to hear it, HAL. Sing it for me.
HAL: It's called "Daisy." Daisy, Daisy, give me your answer do. I'm half crazy all for the love of you. It won't be a stylish marriage, I can't afford a carriage. But you'll look sweet upon the seat of a bicycle built for two.

Daisy really was the first song sung by a computer, an IBM 7094 computer at Bell Labs in 1961, but I digress. WolframTones is, in my biased opinion, the easiest, most powerful, and most flexible free computer-generated music software ever released. It's certainly much simpler than programming a UNIVAC and hiring a quartet to play the output. Other computer music sites include Automatous Monk, The Sound of Mathematics, SynthZone, Metamath Music, Chuck, Isle Ex, rand()%, Synestesia, Pirkle's Music Studio, Karma Lab, SoundTrek, Dennis H.Miller, and ArtWonk. (Feel free to tell me what I missed.)

Whether opening car doors or ringing a phone, cellular automata are fascinating tools, and I thank Numb3rs for using this interesting type of math in their show. Since my column a few months back, the show has done very well (often #1 for the night), and has had support from Cal-Tech and Wolfram Research. Joining the Numb3rs team this season are Texas Instruments (with an excellent series of math activities (here's one on cellular automata)) and the National Council of Teachers of Mathematics. The Sloane Foundation has called Numb3rs the smartest show on television. It's a pleasure to be a part of it all.

I'd like to thank Paramount, CBS, the Numb3rs crew, and Wolfram Research for assisting with this column. Special thanks to David Krumholtz for chalking the CA on the board.


David M. Halbfinger, "Pentagon's New Goal: Put Science Into Scripts", New York Times, August 4, 2005.

Lejaren Hiller, "Computer Music Retrospective", Wergo compact disc #WER 60128-50.

Ed Pegg Jr, "WolframTones Launched by Wolfram Research,"

Eric W. Weisstein. "Cellular Automaton." From MathWorld--A Wolfram Web Resource.

Eric W. Weisstein. "Totalistic Cellular Automaton." From MathWorld--A Wolfram Web Resource.

Math Games archives.

Comments are welcome. Please send comments to Ed Pegg Jr. at

Ed Pegg Jr. is the webmaster for He works at Wolfram Research, Inc. as an associate editor of MathWorld, and as administrator of the Mathematica Information Center.