You are on page 1of 236

AMS / MAA SPECTRUM VOL 100

Barrycades
and Septoku
Papers in Honor of
Martin Gardner
and Tom Rodgers

Thane Plambeck
Tomas Rokicki
Editors
Barrycades and Septoku
Papers in Honor of Martin Gardner
and Tom Rodgers
Editors AMS/MAA SPECTRUM

VOL 100

Barrycades and Septoku


Papers in Honor of Martin Gardner
and Tom Rodgers

Thane Plambeck
Tomas Rokicki
Editors
2019 Editorial Committee
James J. Tattersall, Editor

Michael Barany Andrew Beveridge Virginia M. Buchanan


Thomas L. Drucker Evan D. Fisher Donna L. Flint
Richard K. Guy Dominic Klyve John Lorch
Cayla Danielle McBee
2010 Mathematics Subject Classification. Primary 00A08, 00A09, 00B10, 97A20.

For additional information and updates on this book, visit


www.ams.org/bookpages/spec-100

Library of Congress Cataloging-in-Publication Data


Names: Plambeck, Thane E., editor. | Rokicki, Tomas, editor. | Gathering 4 Gardner Foundation.
Title: Barrycades and septoku : papers in honor of Martin Gardner and Tom Rodgers / Thane Plam-
beck, Tomas Rokicki, editors.
Description: Providence, Rhode Island : American Mathematical Society, [2020] | Series: Spectrum ;
volume 100 | Copyrighted by Gathering 4 Gardner, Inc. | Includes bibliographical references.
Identifiers: LCCN 2019041150 | ISBN 9781470448707 (paperback) | ISBN 9781470455187 (ebook)
Subjects: LCSH: Mathematical recreations. | Puzzles. | Gardner, Martin, 1914–2010. | Rodgers, Tom,
1943–2012 | AMS: General – General and miscellaneous specific topics – Recreational mathe-
matics [See also 97A20]. | General – General and miscellaneous specific topics – Popularization
of mathematics. | General – Conference proceedings and collections of papers – Collections of
articles of general interest. | Mathematics education – General, mathematics and education –
Recreational mathematics, games [See also 00A08].
Classification: LCC QA95 .B3585 2020 | DDC 793.74–dc23
LC record available at https://lccn.loc.gov/2019041150

Copying and reprinting. Individual readers of this publication, and nonprofit libraries acting for
them, are permitted to make fair use of the material, such as to copy select pages for use in teaching
or research. Permission is granted to quote brief passages from this publication in reviews, provided
the customary acknowledgment of the source is given.
Republication, systematic copying, or multiple reproduction of any material in this publication is
permitted only under license from the American Mathematical Society. Requests for permission to
reuse portions of AMS publication content are handled by the Copyright Clearance Center. For more
information, please visit www.ams.org/publications/pubpermissions.
Send requests for translation rights and licensed reprints to reprint-permission@ams.org.

© 2020 by Gathering 4 Gardner, Inc. All rights reserved.


Printed in the United States of America.

∞ The paper used in this book is acid-free and falls within the guidelines
established to ensure permanence and durability.
Visit the AMS home page at https://www.ams.org/
10 9 8 7 6 5 4 3 2 1 25 24 23 22 21 20
Contents

Preface ix

Remembrances xi
Elwyn Berlekamp xi
Nancy Blachman xii
Rob Jones xiii
Dick Esterle xv

Part 1 Sequences, Tiling, and Packing 1

1 Eight Hateful Sequences 3


N. J. A. Sloane

2 Building Barrycades and Constructing Corrals 11


Richard K. Guy

3 Limited Placements of Polyominoes on Rectangles 19


Solomon W. Golomb

4 Polyominoes on a Multicolored Infinite Grid 29


Hans Hung-Hsun Yu

Part 2 Fun and Games 37

5 A Chess Tribute to John Horton Conway 39


Carlos Pereira dos Santos

6 Some New Combinatorial Games 51


Aaron N. Siegel

7 Factor Subtractor 59
Barry Cipra

v
vi Contents

8 The Mathematics of Septoku 63


George I. Bell

Part 3 History 77

9 Thirty Years of Computer Cubing: The Search for God’s


Number 79
Tomas Rokicki

10 Nim-like Games: An Ancestry 99


Lisa Rougetet

Part 4 Puzzles 113

11 Triangles of Absolute Differences 115


Brian Chen, YunHao Fu, Andy Liu, George Sicherman, Herbert
Taylor, and Po-Sheng Wu

12 Generalization of a Puzzle Involving Set Partitions 125


Michael L. Fredman, Daniel A. Kleitman, and Peter Winkler

13 A Generalization of Retrolife 131


Yossi Elran

14 Coins of Three Different Weights 139


Tanya Khovanova and Konstantin Knop

15 Rubber Bandzzles:
Three Mathematical Puzzle-Art Challenges 155
George Hart

Part 5 Art, Sculpture, and Design 161

16 Comet! 163
George Hart

17 Developing Topsy Turvy and Number Planet 173


M. Oskar van Deventer and Igor Kriz
Contents vii

Part 6 Magic and Miscellany 181

18 Coin-Flipping Magic 183


Nadia Benbernou, Erik D. Demaine, Martin L. Demaine,
and Benjamin Rossman

19 Three Puzzle Fonts 203


Erik D. Demaine, Martin L. Demaine, Belén Palop, and Jason
Ku
Preface

This volume continues a series of books (Pegg et al., 2009; Wolfe and Rodgers,
2002; Gardner et al., 2008, 2009, 1999) containing papers contributed to the Gath-
ering 4 Gardner (G4G) meetings that have been taking place in Atlanta, Geor-
gia, every two years since the early 1990s.
In 1991, Thomas Malin Rodgers, Jr., an Atlanta-based entrepreneur, philan-
thropist, investor, and puzzle and book collector, conceived the idea of bringing
together fans of Martin Gardner for a meeting. Contacting many people directly
via phone calls, he received an enthusiastic response, and the first Gathering 4
Gardner (G4G1) took place in the spring of 1993. Martin Gardner attended this
first Gathering, and attendees exchanged papers and gifts amongst themselves
on many topics, principally including recreational mathematics, but also magic,
mathematical art, and puzzle-related content.
Papers contributed to the initial Gathering and subsequent ones (most re-
cently G4G11, in the spring of 2014) have appeared in several previous volumes
(see “Further Reading”, below), and this volume continues the series with contri-
butions both from original G4G participants over 20 years ago as well as students
as young as fifteen years old when they wrote their included papers.
Rodgers indefatigably continued organizing these meetings, and advising the
nonprofit G4G Foundation organized in 2006 to support them, almost until the
very moment of his death in the spring of 2012.
We’ve chosen to dedicate this volume to his memory.
Thank you, Tom!

Thane Plambeck and Tomas Rokicki

Acknowledgments
The editors are grateful for the encouragement of Stephen Kennedy and the MAA
publications staff.

ix
x Preface

Further Reading
M. Gardner, E. R. Berlekamp, and T. Rodgers (1999). The mathemagician and pied
puzzler: a collection in tribute to Martin Gardner. A. K. Peters, Natick, Mass.
M. Gardner, E. D. Demaine, M. L. Demaine, and T. Rodgers (2008). A lifetime
of puzzles: A collection of puzzles in honor of Martin Gardner’s 90th birthday.
A. K. Peters, Ltd., Wellesley, Mass.
M. Gardner, E. Pegg, A. H. Schoen, and T. Rodgers (2009). Mathematical Wizardry
for a Gardner. A. K. Peters, Wellesley, Mass.
E. Pegg, A. H. Schoen, and T. Rodgers (2009). Homage to a pied puzzler. A. K.
Peters, Wellesley, Mass.
D. Wolfe and T. Rodgers (2002). Puzzlers’ tribute: a feast for the mind. A. K. Peters,
Natick, Mass. http://site.ebrary.com/id/10159715.
Remembrances

I
I met Tom Rodgers in the late 1980s at a puzzle party in Livermore, CA. Soon
thereafter, he recruited me to help him organize the first Gathering 4 Gardner.
He concurrently invited Mark Setteducati to invite some magicians. I invited
some of the mathematicians whom I knew to be fans of Martin Gardner, and we
all came to G4G1 in Atlanta. My wife and our son came too. Tom showed us his
collections of puzzles and books, and we met his family. Buck Rodgers was going
to spend part of his summer at one of the language camps in northern Minnesota,
which inspired David Berlekamp to go to another one there.
From the beginning, Tom was always the driving force behind the Gather-
ings. Under his leadership, they provided the forum for many wonderful con-
tributions to recreational mathematics. Some of them are documented in the
Tribute volumes, the first six of which Tom coedited. Others were distributed in
the puzzle exchanges. G4G also provided a gathering point and erudite audience
for some world-class magicians and mathematical artists, many of whom were
personally recruited by Tom. He was also the Gatherings’ most generous finan-
cial supporter. In later years, he hosted visits by all attendees at each Gathering to
a big celebration at his Japanese-style house and grounds. These events became
one of the major attractions of the Gatherings.

Elwyn Berlekamp

xi
xii Remembrances

II
At my first Gathering 4 Gardner1 —G4G9 at the Ritz hotel in Atlanta—I arrived
during dinner, after registration was closed, and soon found myself being inter-
rogated by Tom Rodgers to make sure I wasn’t crashing the conference, since I
didn’t have a badge. For the rest of the Gathering, Tom checked in with me sev-
eral times each day to make sure I was settling in comfortably and connecting
with people I found interesting.
The thought-provoking presentations, the magic shows, the art exhibit, and
the attendees made G4G among the most intriguing conferences I’ve attended.
After G4G9, Tom invited me to join the Gathering 4 Gardner Celebration
of Mind2 host committee and encouraged me to invite women, minorities, and
young people to G4G conferences. Practically daily, Tom sent me fascinating
emails and he also sent me the book Complexities: Women in Mathematics. I put
together a list of over 20 people with short bios of each one and, at Tom’s request,
invited them all.
In December of 2011, Tom asked me to join the G4G board of directors; while
I was deeply honored at the invitation, I told Tom I wanted to attend a board meet-
ing before deciding. At the board meeting at Tom’s house on Saturday, March 31,
2012, which coincided with the G4GX (the 10th G4G) conference, Tom was ob-
viously in poor health, a fraction of his former self, sitting in a wheelchair. Tom
told me that he hadn’t been sleeping and that he wasn’t able to eat. Nevertheless,
he was fired up when he began the meeting and told the board that we needed
to get the Gathering 4 Gardner Foundation on a solid financial footing. When he
spoke, he sounded just like he did before cancer ravaged his body.
His passion and commitment persuaded me to join the board.
Thank you, Tom, for enriching my life.

Nancy Blachman
Founder, Julia Robinson Mathematics Festival

1 Taking place every two years in Atlanta and honoring the legacy of the late Martin Gardner,

the Gathering 4 Gardner (G4G) brings people together from around the world to explore, create, and
experience that Aha! moment when disparate bits of knowledge converge to create a new discovery.
2 In the same spirit, Celebration of Mind (celebrationofmind.org) takes Gathering 4 Gardner

activities to local and online communities, so everyone can share the fun.
Remembrances xiii

III
Devoted to helping people, Tom Rodgers was a man of vision, passion, and action.
Tom cherished civilization and surrounded himself with objects (and people) that
evinced and propelled it. Known to enjoy life’s finer things, Tom respected those
who had attained them as he had, through education and work. He also loved
to figure things out and appreciated journeys of discovery. Like Martin Gardner,
Tom valued curiosity and derived great satisfaction from getting people to use
their minds—especially those typically not so inclined. He inspired students,
educators, and artists. His life made the world better.
Tom and I met at one of Jerry Slocum’s puzzle parties. Neighbors during
the all-day puzzle exchange, we spent much of it getting to know each other. He
enjoyed sharing his knowledge and I eagerly soaked it up. The next year, I was
honored to receive an invitation to a G4G conference.
In G4G Tom created an oasis where especially curious people could engage,
collaborate, and celebrate their delightful idiosyncrasies. What a thrill for me, as
a first-timer, to find myself among so many people eager to share discoveries that
had piqued or rewarded their curiosity. Spirited exchanges abounded: questions,
strategies, and wonder were everywhere. Numerous insights and partnerships
trace their origins to these curiosity-fueled interactions.
Tom fashioned G4G as a progress-dedicated utopia which valued respect,
fairness, openness, candor, beauty, ingenuity, virtuosity, and generosity. Dur-
ing conferences, we gather in a giant ballroom for hours on end, with speaker
after speaker attempting to arouse our enthusiasm. Many do and a few really
do. To those that don’t, we show more than enough appreciation to keep them
trying. G4G presentations emphasize math, puzzles, and games but attendees
especially enjoy (as Tom did) artists whose work strongly engages the mind. I
vividly recall John Edmark receiving thunderous applause while demonstrating
his kinetic sculptures (one is now in the Museum of Modern Art Design Store).
Crucially, the evenings offer the most accessible and irresistible brain-teasers of
all: the magicians, challenging us to figure out how they do it.
Leading by example, Tom upheld a tradition of welcoming the several hun-
dred G4G attendees to his home for an afternoon of loosely structured fun. Situ-
ated on a glorious property, finely landscaped to evoke the great palaces of Kyoto,
Tom’s house was a masterpiece of hand-rendered Japanese esthetic. His hospi-
tality included opportunities to explore his vast collections of puzzles, books, and
art. He could not have been more welcoming, and his standard influenced every-
one lucky enough to experience it.
Tom’s medical diagnosis forced him to work fast. He had much to preserve
and many duties to transfer. G4G was at the top of his list. It was his personal gift
to humanity, his legacy, and it was in danger. For 20 years, he had operated it in
a tightly controlled, personal way. Suddenly, he needed a succession plan. Two
xiv Remembrances

weeks before he died, Tom called six of us to his home to form a leadership group
and receive his instructions. It was intensely emotional and extremely powerful
to be with Tom as he branded us with his searing devotion to all that G4G is and
means.
Sparked by a compelling vision—individual intellectual engagement through
benevolent collaboration, enhancing community prosperity—Tom Rodgers suc-
cessfully launched a movement whose vast potential remains largely untapped.
G4G’s value, while obvious to those it has touched, defies trite categorization.
This makes it challenging for conventional grant-makers to embrace. Conse-
quently, the G4G community itself must step into Tom’s shoes and accept re-
sponsibility for G4G’s future.
The G4G Foundation, the organization that administers the G4G programs,
relies on the G4G community’s financial support and welcomes G4G community-
members’ involvement in the discourse shaping G4G’s trajectory. For the first
20 years of its existence, Tom sustained G4G, largely with seemingly unfettered
access to his personal time and resources. This high calling has now shifted to
the community he created.

Rob Jones
Remembrances xv

IV
Can you imagine? That is something I heard Tom say more than a few times. I
can still hear it in his special inflection, and enjoy the sound.
And though it was often said in response to something thought over the top,
as I think about him, it’s a fitting phrase, for he truly did imagine, and asked
anyone near him to do so as well. He kept his eye on the Gathering as a special
place to foster that kind of curiosity and camaraderie. He loved it, with all the
attendant problematics of love. My first introduction was at G4G7, and I didn’t
really get to know Tom until G4G9. After that, we began working toward the
AHA retrospective exhibit for G4G10. My first impression of G4G was what a
special event. Like Martin Gardner’s book titles, G4G contained all the elements
of surprises, insights, and curiosity one wouldn’t expect. It was a blast.
Tom had a knack for enlisting one to volunteer beyond one’s expectations of
what they might like, and could deliver, and surprisingly do it and feel good about
it. Tom was like the ringmaster at a carnival and the host of a party almost out of
control. Sarah was part of that behind-the-scenes support as well as his children,
along with many other volunteers. A few times I saw Scott juggling for his life
as he tried to fulfill a last minute almost impossible request of Tom. And like
something family run, G4G has the flavor and hospitality that includes coming
out to the house and gardens which is still one of the most memorable aspects
for the many who attend.
Through this I got to know Tom and how close a friend he was to Martin
Gardner. Whenever I stayed at the house, his big table was covered in newly
arrived books, puzzles, and curiosities from anywhere for him to review and ex-
amine. He did it with a clear delight. He welcomed visitors and was happy to
talk. With his eye on inclusiveness, it was evident that he saw the role of G4G as
a special place to foster and enrich the qualities he and Martin Gardner so loved,
and by extension, the world.

Dick Esterle
Part 1

Sequences, Tiling, and Packing


Many interesting problems in recreational mathematics involve ordering or
packing specific things, such as numbers in magic squares or nonattacking queens
on a chessboard. The first four papers in our collection are about arranging items:
numbers in sequences, logs in rows, polyominoes in rectangles, and finally, poly-
ominoes on an infinite colored plane.
1
Eight Hateful Sequences
N. J. A. Sloane

Dear Martin Gardner:


In your July 1974 Scientific American column you mentioned the Hand-
book of Integer Sequences, which then contained 2372 sequences. Today
the On-Line Encyclopedia of Integer Sequences (the OEIS) (Sloane, 2010)
contains 1400001 sequences. Here are eight of them, suggested by the
theme of the Eighth Gathering For Gardner: they are all infinite, and all
’ateful in one way or another. I hope you like ’em! Each one is connected
with an interesting unsolved problem.
Since this is a 15-minute talk, I can’t give many details—see the entries in the
OEIS for more information, and for links to related sequences.

1.1 Hateful or Beastly Numbers


The most hateful sequence of all! These are the numbers that contain the string
666 in their decimal expansion:
666, 1666, 2666, 3666, 4666, 5666, 6660, 6661,
6662, 6663, 6664, 6665, 6666, 6667, . . .
(A051003). This sequence is doubly hateful because it is based on superstition
and because it depends on the fact that we write numbers in base 10.
1 September 10, 2013: there are now 228560 sequences.

3
4 Chapter 1. Eight Hateful Sequences

It has been said that if the number of the Beast is 666, its fax number must be
667; fortunately this has not yet been made the basis for any sequence. (Added
later: unfortunately this is no longer true—see A138563!)
Base-dependent sequences are not encouraged in the OEIS, but nevertheless
many are included because someone has found them interesting or they have ap-
peared on a quiz or a website, etc. One has to admit that some of these sequences
are very appealing.
For example: start with 𝑛; if it is a palindrome, stop; otherwise add 𝑛 to itself
with the digits reversed; repeat until you reach a palindrome; or set the value to
−1 if you never reach a palindrome. Starting at 19, we have
19 → 19 + 91 = 110 → 110 + 011 = 121,
which is a palindrome, so we stop, and the 19th term of the sequence is 121.
The sequence (A033865) which gives the first palindrome that is reached, or
−1 if no palindrome is ever reached, begins:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 11, 33, 44, 55,
66, 77, 88, 99, 121, 22, 33, 22, 55, 66, 77, . . . .
The first unsolved case occurs when we start with 196. Sequence A006960 gives
its trajectory, which begins
196, 887, 1675, 7436, 13783, 52514, 94039,
187088, 1067869, 10755470, 18211171, . . . .
It appears that it never reaches a palindrome, but it would be nice to have a
proof! This is hateful because it is one of those problems that seem too difficult
for twenty-first century mathematics to solve.

1.2 Éric Angelini’s “1995” puzzle


The following puzzle was invented by Éric Angelini in September 2007: Find the
rule that generates the sequence
one nine nine five five nine n i n e f i v e ....
The answer is that if each letter is replaced by its rank in the English alphabet,
then the absolute values of the differences between successive numbers produce
the same sequence:
1, 9, 9, 5, 5, 9, 9, 5, 5, 9, 1, 3, 13, 17, 1, 3,
13, 17, 9, 5, 5, 9, 9, 5, 5, 9, 1, 3, 13, 17, . . .
(A131744). In (Applegate and Sloane, n.d.), David Applegate and I analyzed this
sequence, and showed among other things that only 19 numbers occur (16, 19,
N. J. A. Sloane 5

20, and 22–26 never appear). We determined the relative frequencies of these 19
numbers: 9 occurs the most often, with density 0.173 ⋯.
In English this sequence is unique: “one” is the only number with the prop-
erty that it is equal to the absolute value of the difference in rank between the
first two letters of its name (“o” is the fifteenth letter of the alphabet, “n” is the
fourteenth, and 1 = |14 − 15|). We also discuss versions in other languages. In
French one can begin with either 4 (see A131745) or 9 (A131746), in German
with either 9 (A133816) or 15 (A133817), in Italian with 4 (A130316), in Russian
with either 1 (A131286) or 2 (A131287), and so on.

1.3 Powertrains
What is the next term in the following sequence?
679 → 378 → 168 → 48 → 32 → ?
Answer: 6. The reason is that each term is the product of the digits of the pre-
vious term. Eventually every number 𝑛 reaches a single-digit number (these are
the only fixed points), and the number of steps for this to happen is called the
persistence of 𝑛. 679 has persistence 5, and it is in fact the smallest number with
persistence 5. The smallest numbers with persistence 𝑛 = 1, 2, . . . , 11 are given
in sequence A003001:
10, 25, 39, 77, 679, 6788, 68889, 2677889,
26888999, 3778888999, 277777788888899.
This sequence was the subject of an article I wrote in 1973 (Sloane, 1973), which
Martin Gardner may remember! I conjectured that the sequence is finite, and
even today no number of persistence greater than 11 has been found.
In December 2007, John Conway proposed some variations of “persistence”,
one of which I will discuss here (see (Conway and Sloane, n.d.) for further infor-
mation). If 𝑛 has decimal expansion 𝑎𝑏𝑐𝑑 ⋯, the powertrain of 𝑛 is the number
𝑎𝑏 𝑐𝑑 ⋯, which ends in an exponent or a base according as the number of digits
in 𝑛 is even or odd. We take 00 = 1 and define the powertrain of 0 to be 0.
The OEIS now contains numerous sequences related to powertrains; see
A133500 and the sequences cross-referenced there. For example, the following
numbers are fixed under the powertrain map:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2592, 24547284284866560000000000
(A135385), and we conjecture that there are no others. Certainly, there are no
other fixed points below 10100 .
6 Chapter 1. Eight Hateful Sequences

1.4 Alekseyev’s “123” sequence


This is a question about strings, proposed by Max Alekseyev when he was a grad-
uate student in the Computer Science Department of the University of Califor-
nia at San Diego (personal communication). If we start with the string 12, and
repeatedly duplicate any substring in place, the strings we obtain are
12
112 122
1112 1122 1212 1222
11112 11122 11212 11222 12112 12122 12212 12222

(A130838). These strings must start with 1 and end with 2, but are otherwise
arbitrary. So the number of such strings of length 𝑛 is 2𝑛−2 for 𝑛 ≥ 2.
But what if we start with the string 123? Now the strings we obtain are
123
1123 1223 1233
11123 11223 11233 12223 12233 12333 12123 12323

(A135475), and the number of such strings of length 𝑛 ≥ 3 is
1, 3, 8, 21, 54, 138, 355, 924, 2432, 6461, 17301, 46657, 126656, 345972, . . .
(A135473). The question is, what is the 𝑛th term in the latter sequence? This is
hateful because one feels that if this sequence was only looked at in the right way,
there would be a simple recurrence or generating function.2

1.5 The Curling Number Conjecture


Let 𝑆 = 𝑆1 𝑆2 𝑆3 ⋯ 𝑆𝑛 be a finite string (the symbols can be anything you like).
Write 𝑆 in the form 𝑋𝑌 𝑌 ⋯ 𝑌 = 𝑋𝑌 𝑘 , consisting of a prefix 𝑋 (which may be
empty), followed by 𝑘 (say) copies of a nonempty string 𝑌 . In general there will
be several ways to do this; pick one with the greatest value of 𝑘. This 𝑘 is called
the curling number of 𝑆.
A few years ago Dion Gijswijt proposed the sequence that is obtained by start-
ing with the string 1, and extending it by continually appending the curling num-
ber of the current string. The resulting sequence (A090822)
1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, 2, 2, 2,
3, 2, 1, 1, 2, 1, 1, 2, 2, 2, 3, 1, 1, 2, 1, 1, . . .
2 It is known from the work of Ming-Wei Wang (Wang, 2000) that the set of strings produced

does not form a regular language, suggesting that this question may not have a simple answer.
N. J. A. Sloane 7

was analyzed in van der Bult et al. (2007), and I talked about it at the Seventh
Gathering 4 Gardner (Sloane, 2009). It is remarkable because, although it is un-
bounded, it grows very slowly. For instance, the first 5 only appears after about
23
1010 terms.
Some of the proofs in that paper could have been shortened if we had been
able to prove a certain conjecture, which remains open to this day. This is the
Curling Number Conjecture, which states that if one starts with any finite string,
over any alphabet, and repeatedly extends it by appending the curling number of
the current string, then eventually one must reach a 1.
One way to attack this problem is to start with a string that only contains 2’s
and 3’s, and see how far we can get before a 1 appears. For an initial string of 𝑛 2’s
and 3’s, for 𝑛 = 1, 2, . . . , 30, respectively, the longest string that can be obtained
before a 1 appears is

1, 4, 5, 8, 9, 14, 15, 66, 68, 70, 123, 124, 125, 132, 133, 134, 135, 136,
138, 139, 140, 142, 143, 144, 145, 146, 147, 148, 149, 150, . . .
(A094004). For example, the best initial string of length 6 is 2, 2, 2, 3, 2, 2. This
produces the string
2, 2, 2, 3, 2, 2, 2, 3, 2, 2, 2, 3, 3, 2, 1, . . . ,
which extends for 14 terms before a 1 appears. It’s hateful because it seems hard
to predict the asymptotic behavior. Does it continue in a roughly linear manner
for ever, or are there bigger and bigger jumps? If the Curling Number Conjecture
is false, the terms could be a “lazy eight” (∞) from some point on!3

1.6 Leroy Quet’s prime-generating recurrence


Leroy Quet has contributed many original sequences to the OEIS. Here is one
which so far has resisted attempts to analyze it. Let 𝑎(0) = 2, and for 𝑛 ≥ 1,
define 𝑎(𝑛) to be the smallest prime 𝑝, not already in the sequence, such that 𝑛
divides 𝑎(𝑛 − 1) + 𝑝. The sequence begins
2, 3, 5, 7, 13, 17, 19, 23, 41, 31, 29, 37, 11, 67,
59, 61, 83, 53, 73, 79, 101, 109, 89, 233, . . .
(A134204). Is it infinite? To turn the question around, does 𝑎(𝑛−1) ever divide 𝑛?
If it is infinite, is it a permutation of the primes? (This is somewhat reminiscent
of the EKG sequence A064413 (Lagarias et al., 2002).) This is hateful because we
do not know the answers!
3 For recent work on this problem, see (Chaffin et al., 2013).
8 Chapter 1. Eight Hateful Sequences

David Applegate has checked that the sequence exists for at least 450 ⋅ 106
terms. Note that 𝑎(𝑛) can be less than 𝑛. This happens for the following values
of 𝑛 (A133242):
12, 201, 379, 474, 588, 868, 932, 1604, 1942, 2006, 3084, 4800, 7800, . . . .

1.7 The 𝑛-point traveling salesman problem


My colleagues David Johnson and David Applegate have been re-examining the
old question of the expected length of a traveling salesman tour through 𝑛 random
points in the unit square (cf. Applegate et al. (2007); Beardwood et al. (1959)). To
reduce the effects of the boundary, they identify the edges of the square so as
to obtain a flat torus and ask for the expected length, 𝐿(𝑛), of the optimal tour
through 𝑛 random points (Johnson, 2008). It is convenient to express 𝐿(𝑛) in
units of “eels” (the expected Euclidean length of the line joining a random point
in the unit square to the center), a quantity which is well-known (Finch, 2003,
p. 479) to be
√2 + log(1 + √2)
= 0.382597858232 ⋯
6
(although our name for it is new!). Then 𝐿(1) = 0, 𝐿(2) = 2 eels, and it is not
difficult to show that 𝐿(3) = 3 eels. David Applegate has made Monte Carlo
estimates of 𝐿(𝑛) for 𝑛 ≤ 50 based on finding optimal tours through a million
sets of random points. His estimates for 𝐿(2) through 𝐿(10), expressed in eels,
are
1.99983, 2.99929, 3.60972, 4.08928, 4.5075,
4.88863, 5.24065, 5.5712, 5.8825, 6.17719.
Observe that the first two terms are a close match for the true values. It would be
nice to know the exact value of 𝐿(4). The sequence {𝐿(𝑛)} is hateful because for
𝑛 ≥ 4 it may be irrational, even when expressed in terms of eels, and so will be
difficult to include in the OEIS.

1.8 Lagarias’s Riemann hypothesis sequence


Every inequality in number theory is potentially the source of a number sequence
(if the inequality states that 𝑓(𝑛) ≥ 𝑔(𝑛), the corresponding sequence is 𝑎(𝑛) =
⌊𝑓(𝑛) − 𝑔(𝑛)⌋). Here is one of the most remarkable examples. Consider the se-
quence defined by
𝑎(𝑛) = ⌊𝐻(𝑛) + exp(𝐻(𝑛)) log(𝐻(𝑛))⌋ − 𝜎(𝑛),
𝑛
where 𝐻(𝑛) = ∑𝑘=1 1/𝑘 is the 𝑛th harmonic number (see A001008 and A002805)
and 𝜎(𝑛) is the sum of the divisors of 𝑛 (A000203). This begins
0, 0, 1, 0, 4, 0, 7, 2, 7, 5, 13, 0, 17, 9, 12, 8, 23, 5, 27, 8, 21, 20, 34, 1, 33, 25, . . .
N. J. A. Sloane 9

(A057641). Jeff Lagarias (Lagarias, 2002), extending earlier work of G. Robin


(Robin, 1984), has shown that proving that 𝑎(𝑛) ≥ 0 for all 𝑛 is equivalent to
proving the Riemann hypothesis! Hateful because it’s hard.

1.9 Acknowledgment
I would like to thank my colleague David Applegate for being always ready to
help analyze a new sequence, as well as for stepping in on several occasions to
keep the OEIS website up and running when it was in difficulties.

Further Reading
D. L. Applegate and N. J. A. Sloane. Éric Angelini’s “1995” puzzle sequence (in
preparation).
D. L. Applegate, R. E. Bixby, V. Chvtal, and W. J. Cook (2007). The Traveling
Salesman Problem: A Computational Study. Princeton University Press.
J. Beardwood, J. H. Halton, and J. M. Hammersley (1959). The shortest path
through many points. Proceedings of the Cambridge Philosophical Society, 55:
299–327.
B. Chaffin, J. P. Linderman, N. J. A. Sloane, and A. R. Wilks (2013). On curling
numbers of integer sequences. Journal of Integer Sequences, 16(13.4.3).
J. H. Conway and N. J. A. Sloane. Powertrains and other sequences (in prepara-
tion).
S. R. Finch (2003). Mathematical constants. Cambridge University Press, New
York. http://search.ebscohost.com/login.aspx?direct=true&scope=
site&db=nlebk&db=nlabk&AN=589155.
D. S. Johnson (2008). Comparability. A talk given at Workshop on Experimental
Analysis of Algorithms: Interfaces between the Statistical and Computational
Sciences, Research Triangle Park, NC.
J. C. Lagarias (2002). An elementary problem equivalent to the Riemann hy-
pothesis. The American Mathematical Monthly, 109(6): 534–543. http:
//www.jstor.org/stable/2695443.
J. C. Lagarias, E. M. Rains, and N. J. Sloane (2002). The EKG sequence. Ex-
perimental Mathematics, 11(3): 437–446. DOI 10.1080/10586458.2002.
10504486.
G. Robin (1984). Grandes valeurs de la fonction somme des diviseurs et hypothèse
de Riemann, Journal de Mathèmatiques Pures et Appliquées, 63: 187–213.
10 Chapter 1. Eight Hateful Sequences

N. J. A. Sloane (1973). The persistence of a number. Journal of Recreational


Mathematics, 6(2): 97–98.
N. J. A. Sloane (2009). Homage to a pied puzzler; see chapter seven, Staggering
sequences, pp. 93–110. A. K. Peters, Wellesley, Mass.
N. J. A. Sloane (2010). The on-line encyclopedia of integer sequences. http://
oeis.org.
F. J. van der Bult, D. C. Gijswijt, J. P. Linderman, N. J. A. Sloane, and A. R. Wilks
(2007). A slow-growing sequence defined by an unusual recurrence. Journal
of Integer Sequences, 10(#07.1.2).
M. W. Wang (2000). On the irregularity of the duplication closure. Bulletin of the
European Association for Theoretical Computer Science, 70: 162–163.
2
Building Barrycades and
Constructing Corrals
Richard K. Guy

2.1 Introduction
Barry Cipra noticed that the partial sums of the numbers {1, 2, . . . , 𝑛} were the
triangular numbers {1, 3, 6, . . . , 1/2 𝑛(𝑛+1)} and asked if there were several differ-
ent arrangements of the numbers from 1 to 𝑛, whose partial sums, other than the
complete sum 1/2 𝑛(𝑛 + 1), form the set of all numbers from 1 to 1/2 𝑛(𝑛 + 1) − 1,
each number appearing just once.
For example, {1, 2, 3, 4} has partial sums 1, 3, 6, 10, while {2, 3, 4, 1} has partial
sums 2, 5, 9, (10) and {4, 3, 1, 2} has partial sums 4, 7, 8, (10), which between them
include all the integers from 1 to 9 exactly once each.
The problem may be visualized as building a barrycade, using logs of lengths
1 to 𝑛 in each layer. We’ll call a barrycade breakfree if it has enough layers so
that joins appear at all possible places across the barrycade, but there are no two
joins one above another. From now on we’ll assume that a barrycade is always
breakfree. The barrycade corresponding to the above example is shown in Fig-
ure 2.1.

11
12 Chapter 2. Building Barrycades and Constructing Corrals

Figure 2.1. A barrycade for 𝑛 = 4

Since the sum of the log-lengths is 𝑛(𝑛+1)/2 and the number of joins in each
layer is 𝑛 − 1, the number of layers is
1
𝑛(𝑛 + 1) − 1 1
2
= (𝑛 + 2)
𝑛−1 2
so that, for a breakfree barrycade, 𝑛 must be even (or 𝑛 = 1).
Figure 2.2 shows breakfree barrycades for 𝑛 = 2, 4, 6, 8, and 10. It seems cer-
tain that they exist for all even values of 𝑛, but we don’t know how to prove that.
Moreover, it also seems that the number of different barrycades, for a given even
value of 𝑛, grows quite rapidly as 𝑛 increases. We won’t count them as different
if they just have their layers in a different order. In fact we’ll always build our
barrycades with the leftmost logs having increasing lengths as we go from top to
bottom.

Figure 2.2. Breakfree barrycades for 𝑛 = 4, 6, 2, 8,


and 10

Check that the barrycades in Figure 2.2 are not only breakfree, but that they
also satisfy the Fink condition (suggested by Alex Fink); that is, they are bal-
anced in the sense that, if we look at them as being made up of 𝑛 − 1 sections of
equal width, the (𝑛 + 2)/2 joins in each section occur just one in each layer. In
Figure 2.3 the sections are separated by dashed vertical lines.
You can also ask how many different barrycades there are, using a particular
set of logs. As we said, we won’t count them as different if we permute the layers.
Richard K. Guy 13

Figure 2.3. A balanced barrycade for 𝑛 = 4

Similarly, we won’t count them as different if they are rotated through 180∘ ,
after which the layers may need resorting. If resorting is not needed, that is, if
rotation leaves the barrycade unchanged, we will call it rotary. If the number of
layers is odd, the middle layer cannot be symmetrical, and the barrycade cannot
be rotary. So rotary barrycades can only occur for 𝑛 of shape 4𝑘 + 2. If, after
rotation and resorting, a barrycade returns to its original state, we will call it re-
flexive.

2.2 How many are there? Can you always find one?
For 𝑛 = 2 there is just one barrycade, which is both balanced and rotary. For
𝑛 = 4 with the set {1, 2, 3, 4}, there are four different barricades, the balanced one
in Figure 2.3 and the three unbalanced ones in Figure 2.4.

Figure 2.4. Three unbalanced barrycades for 𝑛 = 4

And in Figure 2.5 there is a rotary solution of the original problem for 𝑛 = 6.

Figure 2.5. A rotary barrycade for 𝑛 = 6

A couple of years ago, Stan Wagon used the problem of building barrycades as
his “Problem of the Week”, and many examples of various sizes were found. Rob
Pratt found examples for 𝑛 = 2, 4, 6, . . . , 26 and rotary examples for 𝑛 = 26, 30, 34,
and 38. Barrycades are a good example of a phenomenon that you often comes
14 Chapter 2. Building Barrycades and Constructing Corrals

Figure 2.6. Five balanced and reflexive barrycades


for 𝑛 = 6

across in combinatorial problems. You are looking for needles in a haystack. The
number of needles is growing exponentially in 𝑛, but the size of the haystack is
growing super-exponentially!
For n = 6 Sam Benner finds 1120 barrycades, of which there are 22 rotary,
34 reflexive, and 1064 others. Barry Cipra tells me that Pavel Curtis had already
found the 22 + 34 = 56. The numbers of these which are balanced are 5 reflexive
and 14 others.
Figure 2.6 shows the balanced and reflexive ones. Notice that the first and
the last two of these barrycades remain the same if you rotate the top half and the
Richard K. Guy 15

bottom half separately. Similarly the third and fourth barrycades remain fixed if
you rotate (and hence interchange) the first and third rows and also the second
and fourth rows.
For n = 8, Sam Benner has counted no fewer than 28432700 barrycades, of
which 3368 are balanced. There are no such reflexive (nor rotary) barrycades,
since, with an odd number (five) of rows one would need one of them to be sym-
metrical.

2.3 What other log-lengths will do?


The members of the enrichment class run by Bill Sands and Bob Woodrow also
wanted to know what other (multi)sets of log-lengths would serve to build a
breakfree barrycade. They soon discovered that a necessary condition was that
the sum of the log-lengths should be of shape (𝑐−1)ℎ+1, where 𝑐 is the cardinality
of the set and ℎ is the height of the barrycade, that is, the number of layers.
It’s not hard to see that the sets must contain either {1, 1} or {1, 2} and that no
log-length can exceed the sum of all smaller log-lengths by more than 1.
Austin Law, Nam Song, Desmond Sisson, Hunter Spink, and others discov-
ered the following numbers of sets, but they are not sure if they found all the
possibilities for 𝑐 = 5.
𝑐 1 2 3 4 5
# of sets 1 2 4 7 31
{1𝑐 }, {1 2𝑐−1 }, and {1𝑐−1 𝑐} will do for all values of 𝑐 ≥ 1, 2, and 3, respectively,
where superscripts denote repetitions of the log-length. In addition there are the
following sets:
𝑐 = 3: {1 2 4}
𝑐 = 4: 1 1 2 3, 1 2 3 4, 1 2 3 7, 1 2 4 6
𝑐 = 5: 1 1 1 2 4, 1 1 1 3 3, 1 1 1 3 7, 1 1 2 2 3, 1 1 2 2 7, 1 1 2 3 6, 1 1 2 4 5, 1 1 2 4 9,
1 1 2 5 8, 1 1 3 4 4, 1 1 3 4 8, 1 2 2 2 6, 1 2 2 3 5, 1 2 2 3 9, 1 2 2 4 4, 1 2 2 4 8, 1 2 2 5 7,
1 2 3 3 4, 1 2 3 3 8, 1 2 3 4 7, 1 2 3 4 11, 1 2 3 5 6, 1 2 3 5 10, 1 2 3 7 8, 1 2 4 4 6, 1 2 4 5 5,
1 2 4 5 9, 1 2 4 6 8 .
Checking that these are correct makes for good puzzling. For example, how
can you be sure that 1 2 3 6 9 won’t work?

2.4 Safer in a circle?


Of course, you may want your barrycades to be circular, forming a corral. We
can’t use the ones we’ve built already, because they would have a join from top
to bottom, which would split apart. We need something like Figure 2.7 in which
the two ends are joined together.
16 Chapter 2. Building Barrycades and Constructing Corrals

Figure 2.7. A corral with 𝑛 = 5

The corral in Figure 2.7 isn’t balanced. Can you see why it’s not possible to
have such a solution? Imagine the dashed vertical lines partitioning the corral
into five sections. The logs of length 1 and 2 would each have to straddle these
lines, else two joins would appear at the same level in the same section. As there
are six such logs, two in each of the three layers, two would have to straddle the
same dashed line, resulting in two joins one above the other.
If we use the log-lengths 1, 2, . . . , 𝑛, then the number of layers in a corral is
1
𝑛(𝑛 + 1)1
2
= (𝑛 + 1),
𝑛 2
so now 𝑛 must be odd. Moreover, the argument of the last paragraph holds for all
odd 𝑛, so there are no balanced corrals using these log-lengths. However, there
are again many (multi)sets from which you can build corrals. For 𝑐 = 1 you can
use 𝑛 copies of a log of length 𝑛 for any 𝑛. For 𝑐 = 2, you can use {1, 2𝑛 − 1}
for any 𝑛 and you can always double, treble, etc., the members of any set, giving
{2, 4𝑛 − 2} {3, 6𝑛 − 3}, etc. For example, Figure 2.8 shows a corral using the set
{3, 15}.

Figure 2.8. A corral with log-lengths 3 and 15

So we need only list (multi)sets whose greatest common divisor is 1. Also,


for corrals, the total log-length must be a multiple of 𝑐, the number of logs in a
layer.
Richard K. Guy 17

For 𝑐 = 3, with no claim to completeness, we have found the following sets


that will do: {1, 1, 3𝑛 − 2}, {1, 2, 3}, {1,3,8}, {1,4,4}, {1,4,7}, {1,5,6}, {1,7,7}, {2,2,5},
{2,3,7}, {2,5,5}, {3,4,5}, . . . . Again, we have a number of puzzles and missing proofs
for the impossibility of (some of) the missing sets. Is it true that none of {1,2,6},
{1,2,9}, {1,3,5}, or {2,3,4} are possible? Can you prove it?
The reader can investigate sets of greater cardinality. We conclude with Fig-
ure 2.9 which shows corrals for 𝑛 = 7 and 𝑛 = 9 and three different balanced
corrals for the set {2,3,4,5,6}. Can you find corrals with log-lengths {1, 2, . . . , 𝑛}
for all odd values of 𝑛?

Figure 2.9. Corrals for 𝑛 = 7, 𝑛 = 9, and three for


the set {2,3,4,5,6}
18 Chapter 2. Building Barrycades and Constructing Corrals

2.5 Barcarolles and carousels?


Musically inclined readers will want to read the barrycades and corrals as melo-
dies and rounds. Some will be more pleasing than others. Do any of them co-
incide with existing tunes or songs? Compare with the .6 waltz in Blanche Des-
cartes, (1964).

Further Reading
Blanche Descartes (1953). Why are series musical? Eureka, 16: 18–20; reprinted
ibid., 26(1964): 29–31.
3
Limited Placements of
Polyominoes on Rectangles
Solomon W. Golomb

In the classic book Polyominoes (Golomb, 1965), numerous methods limiting


where polyominoes can be placed in tiling problems were given. Here are two
more important methods, one based on marking certain squares with dots in a
regular fashion, and another based on a new sequence of color permutations.

Figure 3.1. Problem: To fill a 5×5 square with eight


right trominoes and one monomino, where must
the monomino be placed?

19
20 Chapter 3. Limited Placements of Polyominoes on Rectangles

Figure 3.2. Solution (Necessary): The monomino


must be on one of the nine dotted squares; one right
tromino cannot cover more than one dotted square,
and we have only eight right trominoes.

Figure 3.3. Solution (Sufficient): Solutions are


shown in the three inequivalent cases.
Solomon W. Golomb 21

Figure 3.4. Other results about tiling rectangular


𝑎×𝑏 boards with right trominoes when 𝑎𝑏 is odd are
facilitated by similar considerations. For example,
the 3 × 3 board cannot be tiled with three trominoes,
and Figure 3.4 is an easy way to prove this.

Figure 3.5. Markings (here, for 𝑛 = 7) show that


a 3 × 𝑛 with 𝑛 odd cannot be tiled with 𝑛 right tro-
minoes: there are 𝑛 + 1 dots, each of which must be
covered by a different tromino.
22 Chapter 3. Limited Placements of Polyominoes on Rectangles

Figure 3.6. The 5 × 7 board shown here has twelve


“dotted” squares, and to tile it with eleven trominos
and one domino it is necessary that each of these
twelve tiles covers a dot.

Figure 3.7. There is only one placement (and its


symmetric mirror image) where the domino does
cover a dot, yet the rest of the 5 × 7 board cannot
be tiled with eleven trominoes. It is shown here.
Solomon W. Golomb 23

Figure 3.8. It is easy to cover a 5×11 rectangle with


eighteen right trominoes plus one monomino, since
there are only eighteen (unshown) dots to be cov-
ered. There is only one location for the monomino
(and its symmetric mirror image) on the 5×11 board
where the rest cannot be tiled with eighteen right
trominoes. It is shown in black.

Figure 3.9. The square tetromino


24 Chapter 3. Limited Placements of Polyominoes on Rectangles

Figure 3.10. The 7 × 7 board shown at the left has


sixteen dotted squares, and can be tiled with six-
teen right trominoes plus one monomino, no mat-
ter where the single square is placed. Since the 7 × 7
board has only ten locations inequivalent with re-
spect to the eight-element symmetry group of the
square, only ten positions for the monomino need
to be considered. We further simplify the task by
covering the 7 × 7 board with fifteen trominoes and
one square 2 × 2-tetromino (Figure 3.9), since that
single 1 × 1 square can occupy any corner of the
square-tetromino, leaving a single tromino. It is
therefore sufficient to consider only three locations
of the square tetromino. Hence, on a 7 × 7 board
(as on an 8 × 8 board, as proved by mathematical in-
duction on 2𝑛 × 2𝑛 boards in the Polyominoes book),
a single square can be removed anywhere on the
board, and the rest can be tiled with right trominoes.
Solomon W. Golomb 25

Figure 3.11. “An 8 × 9 rectangle can’t be tiled with


1 × 6 tiles.” Each 1 × 6 tile will cover one square
of each of the six “colors” 𝑎, 𝑏, 𝑐, 𝑑, 𝑒, 𝑓; so twelve
tiles will cover twelve of each color, equally many
of each. But, beyond eleven of each color, there
is one 𝑎, two 𝑏’s, two 𝑐’s, and one 𝑑. (This is an
“old” method of proof.) Note. A theorem of N.G.
de Bruijn states: an 𝐴 × 𝐵 board can be tiled with
1×𝑛 tiles if and only if 𝑛 divides at least one of 𝐴 and
𝐵. His clever proof (which extends to higher dimen-
sions) uses complex numbers! Many other proofs
are known. The 8 × 9 example just given illustrates
my general proof, as given in the second edition of
Polyominoes.
26 Chapter 3. Limited Placements of Polyominoes on Rectangles

Figure 3.12. We now wish to tile the 8 × 9 region


using eleven of the 1 × 6 tiles, plus one 2 × 3 tile.
Where must the 2 × 3 tile be placed? If we use the
coloring from the previous problem, seventeen loca-
tions for the 2 × 3 tile are not ruled out! But in fact,
thirteen of these seventeen don’t work!
Solomon W. Golomb 27

Figure 3.13. An “old” principle (from my earliest


work on polyominoes) states: if a placement in one
location is impossible (e.g., by a coloring argument),
then any placement in a location symmetric to the
impossible one will also be impossible. That is, a
location can only hope to be possible if it and all lo-
cations symmetric to it have not been ruled out. Ap-
plying this to the previous diagram leaves only five
possible locations for the 2×3 tile on the 8×9 region.
Of the seventeen locations (in this coloring) where
a 2 × 3 tile covers one 𝑎, two 𝑏’s, two 𝑐’s, and one 𝑑,
only these five are symmetric only to other such lo-
cations. But the one in the middle does not actually
work! (Using it, the rest cannot be tiled with eleven
1 × 6 tiles!)
28 Chapter 3. Limited Placements of Polyominoes on Rectangles

Figure 3.14. The Successful Coloring. In this new


coloring, it is still true that a 1 × 6 tile, either hor-
izontal or vertical, will cover one of each of the six
“colors”. But now, the only locations where a 2 × 3
tile will cover the “extra” colors (one 𝑎, two 𝑏’s, two
𝑐’s, one 𝑑) are the four corners, as highlighted. (Us-
ing any one of these corners for the 2×3 tile, the rest
can be filled with eleven 1 × 6 tiles—eight horizon-
tal and three vertical.) The novelty of this method
is its use of a different permuted sequence of the six
colors in the horizontal and vertical directions. To
avoid all thirteen of the spurious locations for the
2 × 3 tile in the original coloring, the vertical se-
quence (𝑎𝑏𝑑𝑓𝑐𝑒 and back to 𝑎) has no two adjacent
colors except 𝑎𝑏 that were adjacent in the horizontal
sequence (𝑎𝑏𝑐𝑑𝑒𝑓 and back to 𝑎).

Further Reading
S. W. Golomb (1965). Polyominoes. Charles Scribner’s Sons, New York; revised
second edition, Princeton University Press, Princeton, 1994.
4
Polyominoes on a
Multicolored Infinite Grid
Hans Hung-Hsun Yu

4.1 Polyominoes
A polyomino is a figure consisting of unit squares joined edge to edge. The poly-
ominoes with 1, 2, 3, 4, and 5 squares are called monominoes, dominoes, tromi-
noes, tetrominoes, and pentominoes, and their numbers are 1, 1, 2, 5, and 12,
respectively. They are shown in Figure 4.1. Polyominoes have been made popu-
lar by Henry Dudeney (Dudeney, 1958), Solomon Golomb (Golomb, 1996), and
Martin Gardner (Gardner, 1987, 1989, 2009, 2008). Fabulous acrylic sets may be
ordered from Kadon Enterprises from their website http://gamepuzzles.com.
Many fascinating problems are based on polyominoes, and they are also the focus
of our investigation.
We divide the infinite plane into unit squares by two sets of grid lines which
are mutually perpendicular and evenly spaced. Each square is to be painted
in some color. For a given polyomino, we seek a scheme using the minimum
number of colors so that wherever the polyomino is placed, as long as each of
its squares covers one square of the grid, the covered squares all have different
colors. We now state this formally.

29
30 Chapter 4. Polyominoes on a Multicolored Infinite Grid

Figure 4.1. The 𝑛-polyominoes, to 𝑛 = 5.

Problem
For each polyomino, determine the minimum number 𝑛 of colors for which there
exists an 𝑛-color infinite grid so that wherever the polyomino is placed, the cov-
ered squares all have different colors.

4.2 Analysis
For a polyomino consisting of 𝑛 unit squares, clearly 𝑛 colors are necessary. Also,
clearly, one color is sufficient for the monomino. The checkerboard pattern ex-
tended to the infinite grid shows that two colors are sufficient for the domino.
The three-color infinite grid in Figure 4.2 shows that three colors are sufficient
for the 𝐼-tromino.
Hans Hung-Hsun Yu 31

Figure 4.2. Three colors are sufficient for the


𝐼-tromino.

For the 𝑉-tromino, three colors are not sufficient. Consider a 2 × 2 grid. If
any two of its four squares have the same color, the 𝑉-tromino can cover both
of them and violate the condition of the problem. This shows that 𝑛 ≥ 4. The
four-color infinite grid in Figure 4.3 shows that four colors are sufficient for the
𝑉-tromino.

Figure 4.3. Four colors are sufficient for the


𝑉-tromino, and 𝑛 = 4 for the 𝑁-tetromino and
𝑂-tetromino.

We now turn our attention to the tetrominoes. Since each of them has four
squares, 𝑛 ≥ 4. The four-color infinite grid in Figure 4.3 establishes that 𝑛 = 4 for
32 Chapter 4. Polyominoes on a Multicolored Infinite Grid

Figure 4.4. 𝑛 = 4 for the 𝐼-tetronimo.

the 𝑁-tetromino and the 𝑂-tetromino, while the four-color infinite grid in Figure
4.4 establishes that 𝑛 = 4 for the 𝐼-tetromino.
Consider the region in Figure 4.5 with five unit squares. Every two of them
may be covered by a suitable placement of the 𝑇-tetromino. This shows that 𝑛 ≥
5.

Figure 4.5. 𝑛 ≥ 5 for the 𝑇-tetronimo.

Figure 4.6 shows a five-color infinite grid which establishes that 𝑛 = 5 for
the 𝑇-tetromino.
Consider the region in Figure 4.7, with twelve unit squares. Every two of the
four central squares may be covered by a suitable placement of the 𝐿-tetromino.
Thus four colors, 1, 2, 3, and 4, are needed there. Moreover, any of these squares
and any of the peripheral squares may be covered by a suitable placement of the 𝐿-
tetromino. Thus these four colors may not be used again for the eight peripheral
squares. If only seven colors are available, then one of the three additional colors,
say 5, must be used on at least three peripheral squares. Paint any peripheral
square in color 5. We may assume by symmetry that it is the one shown below.
Then the four squares marked with crosses cannot be painted in color 5. Now
two of the three blank squares must be in color 5, but any two of them may be
covered by a suitable placement of the 𝐿-tetromino. This shows that 𝑛 ≥ 8.
Hans Hung-Hsun Yu 33

Figure 4.6. A five-color grid that shows 𝑛 = 5 for


the 𝑇-tetromino.

Figure 4.7. 𝑛 ≥ 8 for the 𝐿-tetromino.

Figure 4.8 shows an eight-color infinite grid which establishes that 𝑛 = 8 for
the 𝐿-tetromino.
We conclude our investigation by studying the pentominoes. Since each of
them has five squares, 𝑛 ≥ 5. The five-color infinite grid in Figure 4.6 establishes
that 𝑛 = 5 for the 𝑋-pentomino, while the five-color infinite grid in Figure 4.9
establishes that 𝑛 = 5 for the 𝐼-pentomino.
Consider the region in Figure 4.7. Every two of the four central squares may
be covered by a suitable placement of the 𝑊-pentomino. Thus four colors, 1, 2,
3, and 4, are needed there. Moreover, if any of the eight peripheral squares are
painted in any of these four colors, there is only one choice for each of them, as
shown in Figure 4.10. None of these four colors can be used twice on the eight
peripheral squares, as those two squares may be covered by a suitable placement
of the 𝑊-pentomino. By symmetry, we may assume that the square marked 3 on
the top row is painted in color 5. Then neither of the peripheral squares marked
4 may be painted in color 5, and another color is needed. This shows that 𝑛 ≥ 6.
Figure 4.11 shows a six-color infinite grid which establishes that 𝑛 = 6 for
the 𝑊-pentomino.
34 Chapter 4. Polyominoes on a Multicolored Infinite Grid

Figure 4.8. 𝑛 = 8 for the 𝐿-tetromino.

Figure 4.9. 𝑛 = 5 for the 𝐼-pentomino.

Figure 4.10. 𝑛 ≥ 6 for the 𝑊-pentomino.


Hans Hung-Hsun Yu 35

Figure 4.11. 𝑛 = 6 for the 𝑊-pentomino.

The other nine pentominoes all contain the 𝐿-tetromino, so that 𝑛 ≥ 8.


The eight-color infinite grid in Figure 4.8 establishes that 𝑛 = 8 for seven of
them, namely, the 𝐹-, 𝐿-, 𝑁-, 𝑃-, 𝑇-, 𝑈-, and 𝑌 -pentominoes. For the 𝑉- and 𝑍-
pentominoes, consider a 3 × 3 grid. If any two of its nine squares have the same
color, the 𝑉- or 𝑍-pentomino can cover both of them and violate the condition of
the problem. This shows that 𝑛 ≥ 9. The nine-color infinite grid in Figure 4.12
shows that nine colors are sufficient for the 𝑉- or 𝑍-pentomino.

Figure 4.12. Nine colors are sufficient for the 𝑉- or


𝑍-pentomino.
36 Chapter 4. Polyominoes on a Multicolored Infinite Grid

4.3 Conclusion
We have now determined the values of 𝑛 for the monomino, domino, trominoes,
tetrominoes, and pentominoes. Although it might be tempting to try the same
for all hexominoes, the complexity of the case analysis is daunting. A natural
question that emerges here is: Is it possible to deduce a general formula of 𝑛
for all polynomials? This is, as far as the author is concerned, a very difficult
problem. As a demonstration of the difficulty, the best asymptotic upper bound
of 𝑛 for 𝑘-minoes that the author can get is (8/25)𝑘2 , which may or may not be
sharp. Many similar problems await the reader’s exploration.

Further Reading
H. E. Dudeney (1958). Canterbury Tales, see the chapter, The Broken Chessboard,
pp. 119–121. Dover Publications.
M. Gardner (1987). Time travel and other mathematical bewilderments, see the
chapter, Tilings with Polyominoes, Polyiamonds and Polyhexes, pp. 177–187.
W.H. Freeman, New York
M. Gardner (1989). The Mathematical Magic Show, see the chapter, Polyominoes
and Rectification, pp. 172–187. Mathematical Association of America.
M. Gardner (2008). Hexaflexagons, probability paradoxes, and the Tower of Hanoi.
Cambridge University Press, Cambridge–New York
M. Gardner (2009). Sphere Packing, Lewis Carroll and Reversi, see the chapter,
Polyominoes and the Fault-free Rectangles, pp. 160–174. Cambridge Univer-
sity Press.
S. W. Golomb (1996). Polyominoes: Puzzles, Patterns, Problems, and Packings.
Princeton University Press. http://www.ebook.de/de/product/3636648/
solomon_w_golomb_polyominoes_puzzles_patterns_problems_and_
packings.html.
Part 2

Fun and Games


Games provide a rich set of interesting problems. We draw our next four
papers from this category. The first two papers involve John Horton Conway
and game theory. The first is based on the classic game of chess, and the second
discusses some much newer games. The third paper introduces a game similar
to Nim but is based on factoring integers. The fourth presents a visually striking
variant of Sudoku called Septoku.
5
A Chess Tribute
to John Horton Conway
Carlos Pereira dos Santos

5.1 Abstract
Combinatorial game theory, co-invented by John Horton Conway, describes an
amazing structure that relates specific games and various types of numbers. This
paper constitutes a chess tribute to Conway’s idea. A not artificial chess prob-
lem related to the discovery of the dyadic numbers is presented. Its construc-
tion was inspired by a “mysterious” well-known game played by the world chess
champions Jose Raul Capablanca of Cuba and Emanuel Lasker of Germany. This
is yet another example of the power of abstraction in mathematics: a similar
mathematical idea may be useful in diverse situations.

5.2 Introduction
In the early twentieth century, the mathematical analysis of nim, made by the
American mathematician Charles L. Bouton (Bouton, 1901) was the starting
point, albeit unconsciously, of the birth of a new mathematical subject. Later,
with the publication of the On Numbers and Games (Conway, 1976), by John Hor-
ton Conway, and Winning Ways (Berlekamp et al., 1982), by Elwyn Berlekamp,
John Horton Conway and Richard Guy, combinatorial game theory established

39
40 Chapter 5. A Chess Tribute to John Horton Conway

itself permanently in academia. The ideas proposed by these eminent mathe-


maticians revealed adequate to study a large class of very different combinatorial
rulesets.
Combinatorial game theory (CGT) studies games with perfect information
where two players take turns moving. Under normal play, the last player to move
wins; under misère play, the last player to move loses. In this text, we will just
consider normal play. A restricted class of combinatorial games, used in the con-
ception of the theory, can be informally defined in the following way.
A combinatorial game is a game that satisfies the following conditions:
(1) There are two players who take turns moving alternately;
(2) No chance devices such as dice, spinners, or card deals are involved, and each
player is aware of all the details of the game state at all times;
(3) The rules of a combinatorial game ensure that, even ignoring the alternating
move condition, there is no infinite sequence of legal moves;
(4) The winner is determined on the basis of who made the last move.
A classical example is the blue-red hackenbush.

Figure 5.1. hackenbush girl.

There are two players, one can only remove red edges and the other can only
remove blue edges. Alternately, each player removes one edge. After a removal,
all edges disconnected to the ground also disappear. For example, in Figure 5.1,
if the red hair is removed, no more edges are removed. However, if the stem of
the girl is removed then the same thing happens with the arms, the head and the
hair.
The British mathematician John Horton Conway (1937– ), one of the greatest
mathematicians of our time, proposed a mathematical way to analyze rulesets
Carlos Pereira dos Santos 41

Figure 5.2. John Horton Conway. (Photograph by


Thane Plambeck. Wikimedia Commons. This file is
licensed under the Creative Commons Attribution
2.0 generic license https://creativecommons.
org/licenses/by-2.0/deed.en.)

like hackenbush. In the following, we give an explicit argument for a very first
step, as motivation for the second section. Consider a hackenbush position
without edges:

In this case, the players have no options. Using the standard notation of CGT, we
use brackets and we write the blue options to the left of a bar (Left player, blue)
and the red options to the right (Right player, red). The game value is
{ | }.
The game has a form without options. Define
{ | } = 0.
Consider now the following position with a blue edge.
42 Chapter 5. A Chess Tribute to John Horton Conway

In this case, Left (blue) has a move. She may move to the previous position (0).
Thus, the game value is
{0 | }.
It is not hard to define the position as an advantage of one move for Left. Define
{0 | } = 1.
The answer can be found in books of the first grade! The crucial idea is there for
those who understood fundamental concepts as “whole”, “parts”, or “fractions”.
Consider Figure 5.3 with questions usually found in books used in elementary
education in Singapore (Hong, 2003).

Figure 5.3. Fractions.


Carlos Pereira dos Santos 43

This page has one of the most important ideas about fractions. 1/2 is one
out of two equal parts that make the whole; 3/4 are three out of four equal parts
that make the whole. Sometimes, students look at 3/4 as a division (3 divided
by 4). However, usually it is not the best way to understand the meaning of
a fraction. When a mathematician writes a fraction, usually he does not want
to divide numbers; he wants to think about the whole and equal parts. Also,
and very important, the shape and nature of the whole and the parts may be
very different. This variability is very present in books used in Singapore (in
fact, this care with important details is the reason why the Singapore method is
successful). Some other elementary books use just a few shapes for the wholes
(pies, pizzas, . . . ). This is a huge pedagogical mistake because it does not transmit
the power of abstraction of a fraction. The whole can be everything—the whole
can be a game!!
About the previous hackenbush position, we need two left components
to balance the red edge. The following position is no longer advantageous to
anyone. Whoever moves loses. Therefore, as in the Singaporean page, since two
components are required to exactly balance one move, John Conway found one
half of a move!

John Conway said in some interviews that the co-invention of CGT was one
of the mathematical achievements he was most proud of (Silva, 2004). In some
conferences he explained how happy he was when discovered the value 1/2 in
the context of games; when he realized the idea he lay down on the floor making
gestures of joy (in the conferences he also did it!). Of course the important thing
was not just the discovery of 1/2 but also its implications. This was a moment
of pure creation where he realized important consequences and a mathematical
structure able to generalize the reals and, in some way, quantify the games. In
the next section, a tribute to this rare moment is presented.

5.3 An interesting chess position


Consider the following chess problem, the main subject of this chapter. If the
reader is a competent chess player, just stop and try to solve it!
44 Chapter 5. A Chess Tribute to John Horton Conway

Figure 5.4. White to play and win (Carlos Santos,


2013).

chess is not a good game to analyze with CGT because it is too global. It
is not usual to analyze a chess position by decomposing it into smaller parts.
However, sometimes, in the presence of zugzwang situations, CGT’s approaches
work. Zugzwang (German for “compulsion to move”) is a situation where one
player is put at a disadvantage because he has to make a move when he would
prefer to pass and make no move. A classical example is the following:

The player who has to move loses his pawn and the game.
Carlos Pereira dos Santos 45

If there are more pieces over the board, the players want to play last with
those pieces. The following example is similar to one edge in hackenbush.
White has an advantage of one move.

Noam Elkies (1966– ), an American mathematician, full professor in Har-


vard, and international grand master of chess problem solving, published the
paper “On Numbers and Endgames” (Elkies, 1996) in which he analyzed some
chess positions with CGT approaches. In his article, Elkies proposed a 1 − 1/2 −
1/2 = 0 chess position, but it is somewhat artificial and does not motivate a real
chess study.

Figure 5.5. 1 − 1/2 − 1/2 = 0 (Elkies, 1999).


46 Chapter 5. A Chess Tribute to John Horton Conway

Let us analyze now the problem of the Figure 5.4. Consider the following
related position.

The component in the upper left corner is a mutual zugzwang for a full point.
Black cannot allow a White promotion due to a quick mate. So, we have the
following lines: 1.h5! gh5 2.h4 (White playing first) and 1. . . h5 (Black playing
first). White wins whoever plays first. Using CGT standard notation,

The game value is {0, {0 | −1}, ∗ | 1}. Experts know that this value simplifies to
{0 | 1} = 1/2 (see (Albert et al., 2007; Berlekamp et al., 1982; Conway, 1976; Siegel,
2013)). The chess value equals one half of a move. Therefore, the following
position is a chess zugzwang of the form 1/2 + 1/2 − 1 = 0.
Carlos Pereira dos Santos 47

This construction was based on a famous blitz game played by two past world
chess champions, Jose Raul Capablanca (1888–1942) and Emanuel Lasker (1868–
1941). No one really knows the precise information regarding this game, but the
winning line was brightly found by Capablanca.

Figure 5.6. Capablanca–Lasker stamp


48 Chapter 5. A Chess Tribute to John Horton Conway

Figure 5.7. Jose Raul Capablanca (left) and


Emanuel Lasker (right), Source for both: Wiki-
media Commons. This file is licensed under the
Creative Commons Attribution-Share Alike 3.0
Germany license.

So, what is the solution for the problem in Figure 5.4? The key is to look for
the 1/2 + 1/2 − 1 = 0 configuration!

1. b5!
1. Rc7? Rb8-+;
1. Ra8? Na8 2.b5 Kb7-+;
Carlos Pereira dos Santos 49

1. Re8!? Ne8 2.b5 (2. Rc8 Bd5!) Ka7 3. Rc8 Nf6 4. Ke6 Nh5 5. Kd6 Nf4, and
Black has enough arguments to save the game; probably the game will finish
with a repetition like 6. Rh8 h5 7. Rh7 Kb8 8. Rh8.
1... Ka7
1...Nb5 2. Re8 dc5 3. Ra8 Kb7 4. Rh8 Nd4 5. Rh6 b5 6. Rg6 b4 7.h5, and the
h pawn is strong enough.
2. Ra8!! Na8
1...Ra8 2. Rc7 Kb8 3. Rc8+-.
3. Rc8! Rc8 4. Kc8
and we reach the 1/2 + 1/2 − 1 = 0 configuration.
It is amazing how a Capablanca–Lasker game, a page from a Singaporean ele-
mentary math book, and a mathematically substantial subject, such as CGT, are
somehow related!

Acknowledgment. I thank Professor Jorge Nuno Silva for his review of the
material as well as useful suggestions.

Further Reading
M. H. Albert, R. J. Nowakowski, and D. Wolfe (2007). Lessons in play: an intro-
duction to combinatorial game theory. A. K. Peters, Wellesley, Mass.
E. R. Berlekamp, J. H. Conway, and R. K. Guy (1982). Winning ways, for your
mathematical plays. Academic Press, London–New York.
C. L. Bouton (1901). Nim, a game with a complete mathematical theory. Annals
of Mathematics, 3(1/4): 35–39. http://www.jstor.org/stable/1967631.
J. H. Conway (1976). On numbers and games. Academic Press, London–New
York.
N. Elkies (1996). Games of No Chance, see the chapter, On numbers and
endgames: combinatorial game theory in chess endgames, pp. 135–150. Cam-
bridge University Press.
K. Hong (2003). Primary Mathematics, 2B, Textbook. Curriculum Planning &
Development Division Ministry of Education, Singapore. (U.S. Edition).
A. N. Siegel (2013). Combinatorial game theory, Graduate Studies in Mathemat-
ics, volume 146. American Mathematical Society, Providence, RI.
J. N. Silva (2004). Entrevista com John Horton Conway. Boletim Da Sociedade
Portuguesa De Matemática, 51: 49–53.
6
Some New
Combinatorial Games
Aaron N. Siegel

The past ten years have seen exciting theoretical developments in combinatorial
game theory. Alongside these advances there has appeared a crop of new and
fascinating examples—games that exhibit a rich, varied, and often amusing and
bewildering structure. Some of these games are new variations on well-known
themes; others test and expand the boundaries and capabilities of the theory.
This chapter surveys several of the more interesting recent inventions. The
first two games in our survey, Mem and Mnem, are impartial games with ex-
tremely simple rules and a structure that bifurcates in a surprising way into re-
gions of order and chaos. The next, Toppling Dominoes, is a partizan game
in the classical sense, but one with an unusually clear structure. Finally, En-
trepreneurial Chess is an unusual chess variant, played on an infinitely
large board, with repetition allowed. It therefore violates most of the “classical”
restrictions on combinatorial games, but it nonetheless has a robust and coherent
theory.
None of these games were invented by me. Mnem was introduced by Con-
way; Toppling Dominoes by Richard Nowakowski; and Entrepreneurial
Chess by Berlekamp and Pearson. Some familiarity with combinatorial game
theory is assumed (see, e.g., (Siegel, 2013)); the discussion of Mem and Mnem
uses only the impartial theory, while the others use the partizan theory and no-
tation as described in Winning Ways (Berlekamp et al., 2003).

51
52 Chapter 6. Some New Combinatorial Games

Taken together, these games illustrate the boundless possibilities of combi-


natorial games. They inhabit a miraculous universe, in which elegant and mys-
terious mathematics springs from a few simple rules.

6.1 Mem and Mnem


Mem and Mnem are deceptively simple impartial games. They were introduced
by Conway a few years ago and, despite their straightforward rules and “obvious”
structure, it appears difficult to prove anything about them! Mem is played with
a heap of tokens. On her turn, a player must remove 𝑘 tokens from the heap,
provided that 𝑘 is at least as large as the number of tokens removed on the prior
turn. If played with multiple heaps, then each heap has its own “memory”.
We can represent a heap of size 𝑛, with memory 𝑘, by a pair of integers 𝑛𝑘 .
Then the legal moves are given by
𝑛𝑘 = {(𝑛 − 𝑖)𝑖 | 𝑘 ≤ 𝑖 ≤ 𝑛}.
In impartial games such as these, every position can be classified as one of
two types: an 𝑁-position, from which the next player to move can force a win; or
a 𝑃-position, from which the previous player can force a win. Every move from
a given 𝑃-position leads to some 𝑁-position, and at least one move from a given
𝑁-position must lead to some 𝑃-position.
Moreover, it can be shown that every position 𝐺 is equivalent to some nim-
heap (i.e., a single-heap position in the game Nim). The size 𝑛 of this nim-heap
is called the nim-value of 𝐺. Every 𝑃-position has 𝑛 = 0, and every 𝑁-position
has 𝑛 > 0.
In the case of Mem, the 𝑃- and 𝑁-positions are easily determined: 𝑛𝑘 is a
𝑃-position if 𝑘 > 𝑛 (since then there are no legal moves), and it is an 𝑁-position
otherwise (since there is a move to 0𝑛 ).
Mnem is just the same, except that a player has the additional option of
adding < 𝑘 new tokens to the heap (but at least one), instead of removing ≥ 𝑘.
When a player exercises this option, the value in “memory” decreases (which
can’t happen in Mem). Denoting a Mem position by 𝑛∗𝑘 , we have
𝑛∗𝑘 = {(𝑛 − 𝑖)∗𝑖 | 𝑘 ≤ 𝑖 ≤ 𝑛} ∪ {(𝑛 + 𝑖)∗𝑖 | 1 ≤ 𝑖 < 𝑘} .
A game of Mnem needn’t ever end. In fact, it’s easy to construct sequences
of moves that traverse an infinite number of distinct positions. For example:
4∗1 → 0∗4 → 3∗3 → 52∗ → 6∗1 → 0∗6 → 55∗ → 94∗ → 12∗3 → 14∗2 → 151∗ → 0∗15 ⋯ .
Here we remove 4 tokens, then add 3, 2, and 1 tokens, leaving 6; then remove 6
tokens, and add 5, 4, 3, 2, 1 tokens, leaving 15; then remove 15 tokens, and so on
....
Aaron N. Siegel 53

But remarkably, both players have to cooperate for this to happen! For ex-
ample, every 0∗𝑘 is a 𝑃-position: the only legal moves are to positions of the form
𝑖𝑖∗ with 𝑖 < 𝑘, which the second player can immediately revert to 0∗𝑖 . If the sec-
ond player sticks to this strategy, then eventually the position 0∗1 will be reached,
which is terminal.
But from 𝑛∗𝑘 with 𝑘 > 𝑛, the only legal moves are to positions (𝑛 + 𝑖)∗𝑖 with
𝑖 < 𝑘, which the second player can revert to 0∗𝑛+𝑖 . So every such 𝑛∗𝑘 is a 𝑃-position,
just as in Mem. And, likewise, every 𝑛∗𝑘 with 𝑘 ≤ 𝑛 is an 𝑁-position, since it has
a move to 0∗𝑛 .
Beyond this, it’s surprisingly hard to say anything at all about the 𝐺-values
of either variant. We don’t even know how to play 2-pile Mem! Yet experimental
evidence suggests an extraordinary amount of structure.
Figure 6.1 shows an intensity plot of 𝐺(𝑛𝑘 ), for all 1 ≤ 𝑛 ≤ 96 and 1 ≤ 𝑘 ≤ 32.
It’s a 32 × 96 grid of boxes, colored in grayscale, and darker shades indicate lower
𝐺-values. The black triangle in the lower left is the space of 𝑃-positions that we
noted above.
What’s striking are the thin triangular bands that extend in quadratic fashion
upwards from the triangle of 𝑃-positions. Just right of 𝑃-region lies a region of
positions with 𝐺-value exactly 1; then a thinner region of positions with 𝐺-value
2; and so on. Amazingly, all of these regions satisfy the following conjecture.

Conjecture 6.1. If 𝑘2 ≥ 𝑛, then 𝐺(𝑛𝑘 ) = ⌊𝑛/𝑘⌋.

Figure 6.1. Intensity plot of the 𝐺-values of Mem.


The value of 𝑛𝑘 is plotted at row 𝑘, column 𝑛 for 1 ≤
𝑛 ≤ 96 and 1 ≤ 𝑘 ≤ 32. Black = 0, White = 14.

Within the region 𝑘2 < 𝑛, the 𝐺-values appear to have a complex structure,
consisting of many interlocking, fractal-like triangles. The interested reader will
enjoy computing a larger table of values and observing their striking regularity.
54 Chapter 6. Some New Combinatorial Games

The geometric structure of Mnem seems very similar to Mem, and Conjec-
ture 6.1 appears true for Mnem as well. However, the fine structure of the 𝑘2 < 𝑛
region differs.
Here’s an indication of how little is understood about these games: we can’t
even prove the following conjecture, which has been verified computationally for
𝑛, 𝑘 ≤ 1000:
Conjecture 6.2. Every Mnem position has a finite 𝐺-value.

6.2 Toppling Dominoes


We turn now to partizan games. Toppling Dominoes, invented by Richard
Nowakowski (Fink et al., 2015), is played with rows of black and white domi-
noes as shown in Figure 6.2.

Figure 6.2. A typical Toppling Dominoes posi-


tion
On her turn, Left may select any black domino and “topple” it East or West
(her choice). The selected domino is removed along with all dominoes from that
row in the chosen direction.
For example, from the position

Left can move to

Although Toppling Dominoes is a straightforward, “classical” combinato-


rial game, it exhibits a remarkable amount of structure. It’s easy to see that every
monochromatic row of dominoes is equal to an integer, for example,

since Left will prefer to topple the black dominoes one at a time. More compli-
Aaron N. Siegel 55

cated numbers can be constructed by mixing dominoes of both colors, say

Here we’ve omitted options that are duplicates under the obvious East-West sym-
metry and used the fact that Left’s move to ∗ is reversible. One can similarly show
that

(Try it!) In fact every dyadic rational number 𝑥 (i.e., whose denominator is a
power of two) can be expressed as a Toppling Dominoes position, using a sim-
ple procedure. Write
𝑚
𝑥= 𝑛
2
in lowest terms (i.e., with 𝑚 odd), and let
𝑚−1 𝑚+1
𝑦= and 𝑧 = .
2𝑛 2𝑛
(In the notation of Winning Ways, 𝑥 = {𝑦|𝑧} in simplest form.) For example, if
𝑥 = 3/8, then 𝑦 = 𝑥 − 1/8 = 1/4 and 𝑧 = 𝑥 + 1/8 = 1/2.
Then 𝑦 and 𝑧 have smaller denominators than 𝑥, so we can recursively con-
struct their domino sequences, say 𝑌 and 𝑍. In the example 𝑥 = 3/8, we have

as noted above.
Now for the trick! Write the sequences for 𝑌 and 𝑍 side-by-side, insert a
black-white pair of dominoes in between them, and amalgamate the whole en-
larged sequence into a single position. This gives a new position 𝑋, which mirac-
ulously has the value 𝑥! For example,

showing that the example in Figure 6.2 has value 3/8.


56 Chapter 6. Some New Combinatorial Games

What makes this construction truly remarkable is that it’s the only way to rep-
resent numbers in Toppling Dominoes. So every number can be represented
uniquely as a single row of dominoes! This remarkable theorem is due to Alex
Fink, and it has an equally surprising proof, the details of which can be found
in (Fink et al., 2015).
Various other familiar values also arise naturally in Toppling Dominoes;
here’s a sampling.

6.3 Entrepreneurial Chess


Here’s an old chess problem, first posed by Simon Norton, and later publicized
by Richard Guy (1991):
With initial position WKa1, WRb2, and BKc3 . . . , what is the
smallest board (if any) that White can win on if Black is given a
win if he walks off the North or East edges of the board?
Berlekamp and Pearson invented Entrepreneurial Chess partly in re-
sponse to this problem (Berlekamp and Pearson, 2003). It is played on a quarter-
infinite board, such as shown in Figure 6.3. Right (White) has a king and rook;
Left (Black) has just a king; the pieces move just as in ordinary chess. However,
instead of moving her king, Left may instead choose to cash out. If Left cashes
out, then the entire position is replaced by an integer 𝑛 equal to the sum of the
row and column positions for her king. For example, if Left chose to cash out in
Figure 6.3(a), the position would be replaced by the integer 7.
Entrepreneurial Chess is loopy. From Figure 6.3(a), Left can do no bet-
ter than to cash out, while Right is constrained to shuttle his king between the
squares bordering his rook. Writing 𝐺 for this position, we have
𝐺 = {7 | 𝐺},
which according to the theory of loopy games in (Berlekamp and Pearson (2003),
Chapter 11) has value 7 + 𝐨𝐯𝐞𝐫.
Aaron N. Siegel 57

Figure 6.3. Entrepreneurial Chess. (a) A typ-


ical position; (b) A pathological position in which
the rook has been captured.

Moreover, Entrepreneurial Chess exhibits some explicitly transfinite val-


ues. Consider the position in Figure 6.3(b), in which Right’s rook has been cap-
tured, and Left is free to run indefinitely far in the Northeast direction. Writing
𝐻 for this value, it’s clear that
𝐻>𝑛
for every integer 𝑛, and its value therefore exceeds every finite game. However
it’s confused with certain transfinite games such as the infinite ordinal 𝜔:
𝜔 = {0, 1, 2, 3, . . . | }
On the sum 𝐻 − 𝜔, Left will prefer never to cash out, and play will continue
forever, so the outcome is a draw.
It can be shown that if 𝐽 is any finite game and 𝐽 > 𝑛 for every integer 𝑛, then
𝐽 > 𝜔 as well. Since 𝐻 > 𝑛 for every 𝑛 but 𝐻 is confused with 𝜔, it follows that 𝐻
is explicitly transfinite. In fact, one can show that, in terms of the Winning Ways
theory, 𝐻 has the remarkable value
𝐻 = on & {0, 1, 2, 3, . . . | 𝐻}.
Berlekamp and Pearson have undertaken a detailed temperature analysis of
Entrepreneurial Chess positions. They also solved Norton’s original prob-
lem: the answer is 8 × 11.

Further Reading
E. R. Berlekamp and M. Pearson (2003). Entrepreneurial chess.
E. R. Berlekamp, J. H. Conway, and R. K. Guy (2003). Winning ways, for your
mathematical plays, volume 2. A. K. Peters, London–New York.
58 Chapter 6. Some New Combinatorial Games

A. Fink, R. J. Nowakowski, A. N. Siegel, and D. Wolfe (2015). Toppling conjec-


tures. Games of no chance 4, 63: 65–76.
R. K. Guy (1991). Unsolved problems in combinatorial games. Proceedings of
Symposia in Applied Mathematics, 43.
A. N. Siegel (2013). Combinatorial game theory, Graduate Studies in Mathemat-
ics, volume 146. American Mathematical Society, Providence, RI.
7
Factor Subtractor
Barry Cipra

Factor Subtractor is a game played with numbers. It is intended to reinforce


basic skills in arithmetic while offering something of interest to professional (or
amateur) mathematicians. It can be played on paper, at the blackboard, or even,
depending on the players’ facility with mental arithmetic, aloud—for example,
during a car trip.
The games start with one player factoring a large number, such as 100, as the
product of two smaller numbers, such as 4 × 25 or 5 × 20. Play then proceeds
with the players taking turns as follows. When it’s your turn, you pick one of the
two factors, subtract it from the product, and then factor the resulting difference,
again as the product of two numbers. For example, suppose player A starts by
factoring 100 = 4 × 25. The game might proceed as follows.
B ∶ 100 − 4 = 96 = 8 × 12
A ∶ 96 − 12 = 84 = 6 × 14
B ∶ 84 − 14 = 70 = 2 × 35
A ∶ 70 − 2 = 68 = 4 × 17
You might have noticed that we haven’t said what the object of the game is,
i.e., how to win it. But note that the numbers being factored are getting smaller
and smaller. So eventually we’re going to run out of numbers. And that’s the
object: to be the first player to reach 0. Let’s see how this might play out by

59
60 Chapter 7. Factor Subtractor

continuing the game above.


B ∶ 68 − 17 = 51 = 3 × 17
A ∶ 51 − 3 = 48 = 6 × 8
B ∶ 48 − 8 = 40 = 4 × 10
A ∶ 40 − 10 = 30 = 2 × 15
B ∶ 30 − 15 = 15 = 3 × 5
A ∶ 15 − 5 = 10 = 2 × 5
B ∶ 10 − 2 = 8 = 2 × 4
A ∶ 8 − 4 = 4 =2 × 2
B∶ 4 − 2 = 2 =1 × 2
A∶ 2−2 = 0
So player A wins. It didn’t have to end that way. As it turns out, each player in
this example made a couple of “bad” plays. The last one occurred when player B
subtracted 15 from 30 instead of 2. Let’s see why this is.
The secret lies in the sequence
4, 9, 10, 14, 16, 18, 22, 25, 26, 28, 30, 34, 36,
40, 46, 48, 49, 54, 55, 56, 62, 63, 65, 66, 68,
74, 75, 76, 80, 81, 84, 88, 90, 94, 96, . . . .
The list goes on and on; these are the one- and two-digit “target” numbers for
the subtraction step, for a which a player can pick a factorization that guarantees
a win. Notice that 15 is not on the list, but 28 is. Therefore, player B should have
played 30 − 2 = 28 instead of 30 − 15 = 15 after A had offered 30 = 2 × 15. Had
he chosen the better number to subtract, B needed to factor 28 as 4 × 7, because
neither 28 − 4 = 24 nor 28 − 7 = 21 is on the list. (The factorization 2 × 14 would
have been a mistake, because it would allow player A to get to either 28 − 2 = 26
or 28 − 14 = 14, both of which are on the list.)
You may notice that 30 is also on the list. This means that player A actually
made a mistake in factoring it as 2 × 15. The “correct” move would have been
30 = 3 × 10, since neither 30 − 3 = 27 nor 30 − 10 = 20 is on the list. For that
matter, player B made a mistake early on, factoring 96, which is on the list, as
8 × 12 instead of 4 × 24; doing so allowed player A to get back on the list, whereas
neither 92 nor 72 would have been.
So where did this list come from? The short answer is recursive computation.
The list, along with its complementary list of “losing” numbers, is built starting
at 1. Obviously 1, along with every prime number 𝑝, is a “loser” because you
can only factor such a number as 𝑝 = 1 × 𝑝, which allows your opponent the
immediate winning move 𝑝 − 𝑝 = 0. (Only a fool, or a very kind parent, would
opt for the nonwinning move 𝑝 − 1 for a prime 𝑝.) The first winning number is
4, since its factorization as 2 × 2 forces your opponent into 4 − 2 = 2 = 1 × 2. The
Barry Cipra 61

numbers 6 and 8 are both losers because the factorizations 6 = 2 × 3 and 8 = 2 × 4


allow your opponent to counter with 6 − 2 = 4 = 2 × 2 and 8 − 4 = 4 = 2 × 2,
respectively. But 9 is a winner, because 9 = 3 × 3 forces your opponent into
9 − 3 = 6 = 2 × 3. Similarly 10 is winner, because 10 = 2 × 5 leaves your
opponent either 10 − 5 = 5 or 10 − 2 = 8, both of which are on the losing list.
Let’s do just a couple more numbers: 12 is on the losing list because 12 = 2×6
allows your opponent to get to the winning number 12 − 2 = 10, and 12 = 3 × 4
allows the winning move 12−3 = 9. Similarly for 15: it’s a loser because 15 = 3×5
allows for 15−5 = 10. But 16 and 18 are on the winning list, with winning moves
16 = 4 × 4 and 18 = 3 × 6.
In general, once you have a complete list of all winning numbers less than
𝑁, you can determine whether or not 𝑁 goes on the list by looking at its possible
factorizations. If there is a factorization 𝑁 = ℎ × 𝑘 for which neither 𝑁 − ℎ nor
𝑁 − 𝑘 is on the list, then 𝑁 goes on the list; otherwise, 𝑁 does not go on the list.
As one more example, let’s show why 72 is not on the list. To do so, we have to
consider all its factorizations: 2 × 36, 3 × 24, 4 × 18, 6 × 12, and 8 × 9. For 2 × 36,
we have 72 − 36 = 36, which is on the list. For 3 × 24, we have 72 − 24 = 48; for
4 × 18, we have 72 − 4 = 68 (and also 72 − 18 = 54, but all you need is one of the
two); for 6 × 12 we have 72 − 6 = 66; and for 8 × 9, we have 72 − 9 = 63.
As mentioned, the list as presented shows all one- and two-digit winning
numbers. The reader may wish to check that it properly omits 97, 98, and 99.
(The easy case is 97: it’s prime.) But what about 100? As noted, player A’s opening
factorization 100 = 4 × 25 was a bad move, because it allowed player B to get to
96. (Actually, 100 − 25 = 75 would have been a better move. As we saw, B
chose the “wrong” factorization for 96. You can check that, for 75, there is no bad
factorization.) Is there a different factorization of 100 that could have guaranteed
A a win?
Once you get started, it’s possible to extend the list indefinitely, with a fairly
simple computer program. Matt Richey at St. Olaf College in Northfield, Min-
nesota, wrote such a program and computed the list up to 𝑁 = 200,000 (Cipra,
2012). There is no readily discernible pattern to the list. Indeed, that’s what
makes it of possible theoretical interest: the sequence (which has yet to appear
in the OEIS (Sloane, 2012), although that’s likely to be self-correcting sometime
soon) is easy to define, but has no obvious properties that allow one to say that a
given (large) number is or isn’t on the list, beyond the one obvious “theorem” that
the list contains no prime numbers. For example, based on the “early returns”
showing 4, 9, 16, 25, and 36 on the list, one might speculate that all squares greater
than 1 are winning numbers. The next square, 49, which is also on the list, would
seem to confirm that hypothesis. But then you get to 64. . . .
Richey’s computation shows there are 366 numbers on the list up to 1000,
4033 up to 10,000, and 42,563 up to 100,000, but it’s unclear whether the fraction
62 Chapter 7. Factor Subtractor

is leveling off or continuing to climb. It would be worthwhile to confirm (or cor-


rect) these calculations and to extend them for another few orders of magnitude.
Just knowing a number is on the list doesn’t in itself say which factorization
guarantees a win (unless the number is the product of two primes, or the square
or cube of a single prime). If there is any pattern here, it has eluded me. Contrast
this with the classic game of Nim, in which the winning positions are easy to spot
and the winning moves are easy to calculate.
Nim is often used as an enrichment activity in math classes, but I believe
Factor Subtractor has its own pedagogical advantages. In particular, even if
students play at random, they are still getting valuable practice doing arithmetic.
And children seem to enjoy playing the game, in part because it provides an obvi-
ous motivation—namely winning—for doing what might otherwise be a tedious
worksheet assignment, and in part (to toss around some educational jargon) be-
cause it “empowers” them to choose which computations they do.
I have a couple of data points worth of support for this: My daughter-in-law,
Sanae Tomita, has used the game with a class of middle-school children, and Kurt
Hedin, a teacher at Bandelier Elementary School in Albuquerque, New Mexico,
whom I met and showed the game, has taught it to his fourth-grade class. I would
be delighted to hear from other teachers who might have occasion to give Factor
Subtractor a try with their students.

Further Reading
N. J. A. Sloane (2012). https://oeis.org/A208980.
Barry Cipra (2012). Personal communication, March 2, 2012.
8
The Mathematics of Septoku
George I. Bell

Sudoku is one of the most popular pencil and paper puzzles, and it has sprouted a
seemingly endless series of variations. Witness the many recent books chock-full
of exciting new variants on the Sudoku theme (Light, 2009; Snyder, 2008; Snyder
and Huang, 2009).
One variation is to consider the puzzle on a hexagonal rather than square
grid. Bruce Oberg invented such a variation in 2006 and named it “Septoku”
(Oberg, 2007). The name derives from the fact that seven is a significant number
for this puzzle. Septoku fit nicely into the seven theme at the 2006 conference
“Gathering 4 Gardner 7”, where it was Bruce Oberg’s exchange gift.
Figure 8.1(a) shows a sample Septoku puzzle, and Figure 8.1(b) shows the
numbering of the 37 hexagonal cells. We will refer to a row of the board to
include not only the horizontal rows, but also the “diagonal rows” parallel to the
other sides of the board. For example the cells numbered {1, 2, 3, 4} form one
row, as do the cells {1, 5, 10, 16} and {3, 8, 14, 21, 28}. We will abbreviate these as
“row 1 → 4”, “row 1 → 16” and “row 3 → 28”. In general, any subset of the board
that must contain distinct symbols will be called a region.
The puzzle is to fill the 37 cells with seven symbols (the numbers 1 to 7) such
that
(1) Each row contains different symbols. There are seven rows in each of three
directions, so 21 rows in all. Note that most rows contain fewer than 7 cells.

63
64 Chapter 8. The Mathematics of Septoku

Figure 8.1. A Septoku puzzle, based on (Oberg


2007), and the Septoku board with cells numbered

(2) The seven circular regions (hexagons of side two) must each contain all
seven symbols. For example, the cells {1, 2, 5, 6, 7, 11, 12} must contain all of
the numbers 1 to 7. These circular regions are denoted by gray circles as a
visual aid to the solver (this helpful suggestion is due to Nick Baxter). Note
that the circles overlap.
Henceforth, we will refer to a circular region as a circle; a particular circle is
identified by its center; i.e., “circle 19” refers to cells {12, 13, 18, 19, 20, 25, 26}.
A puzzle is defined by a blank board with some cells filled in, called givens
(Figure 8.1(a)). The puzzle is to fill out the remaining cells so that the above rules
are satisfied. Such a completed puzzle will be called a valid board. A well-crafted
puzzle has only one solution.
Before reading further, the reader should try the Septoku puzzle in Figure 8.1
and the two harder puzzles in Figure 8.2. To get started with the Figure 8.1 puzzle,
one should be able to deduce the value in cells 13, 24, and 28, and then continue
with cells 12, 11, 16, 25, . . . . For a collection of 28 Septoku puzzles that can be
downloaded and printed, see (Oberg, 2007).

8.1 Seven Septoku Theorems


On the face of it, solving Septoku seems similar to Sudoku. But first impressions
can be deceiving. In fact, Septoku differs significantly because it is much more
tightly constrained. As we will see, Septoku is also much easier to analyze.
In Sudoku, each cell (usually called a square in this case) is in exactly three
regions, a (normal) row, column, and 3 × 3 block. There are nine rows, nine
columns, and nine 3 × 3 blocks, so 27 regions in all. In Septoku there are 28
regions (seven rows in each of three directions, plus seven circles), but the board
George I. Bell 65

Figure 8.2. “Medium” and “hard” Septoku puzzles

is less than half the size of a Sudoku board. Each cell is in at least four regions
and twelve cells are in five regions.
When Bruce Oberg created the first Sudoku puzzles, he noticed that all the
valid boards he generated satisfied additional constraints that were not required
by the puzzle rules. Here we see that these extra constraints on valid boards are
easy to prove.

Theorem 8.1. In a valid Septoku board, each circle center must have a unique
symbol. In other words, 𝑅1 = {6, 8, 17, 19, 21, 30, 32} must be a region (it must con-
tain each symbol 1–7).

Proof. Suppose otherwise. Then there must be some symbol that occurs twice
among the circle centers. The center symbol is clearly unique by the rules of the
puzzle, so without loss of generality, assume a 1 appears in cells 6 and 21. There
must be a 1 in the center circle 19, and this can only be in cell 13 or 25. But if it
is in 25, then circle 8 can contain no 1 at all. Thus there must be a 1 in cell 13.
There must be a 1 in circle 17, and this can now only be in cell 24, and a 1 in circle
32, which can only be in cell 31. But now circle 30 contains two 1’s, so this is not
a valid Septoku board.

Theorem 8.2. In a valid Septoku board, each corner and the center cell 19 must
have a unique symbol. In other words, 𝑅2 = {1, 4, 16, 19, 22, 34, 37} must be a region
(it must contain each symbol 1–7).

Proof. Suppose otherwise. Then there must be some symbol that occurs twice
among the corners (the center symbol is clearly unique by the rules of the puzzle).
Without loss of generality, assume a 1 appears in cells 1 and 22. By Theorem 8.1
there must be a 1 in some circle center, and this can only be in cell 8 or 30. In
either case, there can no longer be a 1 in the center circle 19, so this is not a valid
Septoku board.
66 Chapter 8. The Mathematics of Septoku

Theorem 8.3. In a valid Septoku board, each symbol must appear at least five
times.

Proof. Suppose the symbol 1 appears four or fewer times. By Theorems 8.1 and
8.2 each symbol must appear in a circle center, and in a corner (or once in the
center, 19). If 1 occurs in a corner and one circle center, then this covers only
two of the circles out of seven. There is no way the last two 1’s can cover the
remaining five circles, since one cell is in common with at most two circles. If 1
is in the center, then to cover the remaining six circles we must have a 1 in cells 7,
24, and 27 (or rotational equivalents), but now we have two 1’s in row 3 → 29.
If each symbol occurs five times, this covers only 35 of the 37 cells, so at
least one symbol must occur more than five times. In fact there are only two
possibilities:
(1) Five of the symbols appear five times, two symbols appear six times.
(2) Six of the symbols appear five times, one symbol appears seven times.
We shall see that both of these possibilities can occur.

Theorem 8.4. Not counting reflections, rotations, and permutations, there are only
six valid Septoku boards. Counting reflections, rotations, and permutations as sep-
arate boards, there are 120, 960 = 24 × 7! valid Septoku boards.

The central cell is the key to this board, because whatever number is placed
in cell 19, there are only two patterns for this number over the rest of the board
(up to rotations and reflections). These two patterns are shown in Figure 8.3,
where the dark-shaded cells identify all cells containing the same number. To
derive the two central patterns, start with the central cell 19, and suppose the
pattern includes at least one cell from the interior cells 𝐼 = {7, 11, 14, 24, 27, 31}.
Without loss of generality, we can assume this cell is 7. We must cover circles 17
and 21, so the pattern must include cells 10 and 28, or 15 and 23, and then the
only way to cover circles 30 and 32 is by including cell 31. This gives the pattern
C5. If we assume the pattern includes no cell in 𝐼, we get C7. The two patterns C5
and C7 have 180∘ and 60∘ rotational symmetry, respectively. This is significant
because (as we will see) this symmetry is carried into the full solution.
Surprisingly, there is only one way to place six of the same numbers on the
board (up to symmetry), and there are exactly three ways to place five of the same
numbers on the board (not including the center pattern C5). These patterns are
shown in Figure 8.3. The simplest way to derive these patterns is from the cen-
ter outward: without loss of generality, assume the pattern includes cell 20. We
then need to have a number on circle 17, and this can only be at cell 10 or 11 (or
equivalently by reflection, cell 23 or 24). Cell 10 leads to the unique 6-cell pat-
tern (U6), and cell 11 leads to the three 5-cell patterns: E5, I5, and S5. A potential
George I. Bell 67

C5, “center” C7, “center” U6, “unique”

E5, “equilateral” I5, “isosceles” S5, “scalene”

Figure 8.3. Patterns for a number on a Septoku


board: the two patterns including the center, C5 and
C7; the unique 6-cell pattern U6; the 5-cell patterns
E5, I5, and S5

fourth pattern is obtained from I5 by moving a shaded cell from 8 to 4, but this
pattern violates Theorem 8.2, so it is eliminated. These patterns may be easily
identified by the shapes formed by their interior cells: “unique” U6 (two interior
cells), “equilateral” E5, “isosceles” I5, and “scalene” S5. These shapes are useful
for identifying these patterns in Septoku solutions.
Just as polyominoes are obtained by joining squares, a polyhex is obtained
by joining hexagons. By looking at the patterns formed by all occurrences of a
number, we can view a Septoku problem as a polyhex packing problem! Our
polyhex pieces are the patterns shown in Figure 8.3—these are unusual polyhex
pieces in that they are totally disconnected. Nonetheless, finding a valid Septoku
board is equivalent to packing seven of these polyhexes into the board. We can
rotate or flip any of the polyhexes, but we are not allowed to translate them.
Consider the case where two numbers appear six times, and all other num-
bers five times. We take two copies of the polyhex U6, the central polyhex C5,
and up to four copies of any of E5, I5, or S5. Suppose we take U6 together with
a reflection and rotation of U6—it is either not possible to place the second U6
or not possible to place C5. The only possibility is a copy of U6 together with a
rotation of U6 by 180∘ . The pattern C5 can then be fit in any of three orientations,
and each leads to a unique solution, given in the first row of Figure 8.4.
68 Chapter 8. The Mathematics of Septoku

2 6 4 3 5 6 4 3 5 6 7 3
7 3 5 1 6 2 3 7 1 6 2 3 4 1 6
3 4 1 2 7 5 3 4 1 2 5 7 3 7 1 2 5 4
1 5 6 7 3 2 4 1 5 6 7 3 2 4 4 5 6 7 3 2 1
2 7 5 4 1 6 7 2 5 4 1 6 1 2 5 4 7 6
3 4 2 6 7 3 4 7 6 5 3 4 1 6 5
6 1 3 5 6 1 3 2 6 7 3 2
C5 + 2(U6) + 4(I5) C5 + 2(U6+I5+S5) C5 + 2(U6) + 4(S5)
6 7 3 1 2 7 4 3 5 7 3 6
2 5 4 6 7 3 6 5 1 7 2 6 4 1 7
7 3 1 2 5 4 7 4 1 2 6 5 7 3 1 2 5 4
5 4 6 7 3 1 2 1 5 6 7 3 2 4 4 5 6 7 3 2 1
1 2 5 4 6 7 2 3 5 4 1 7 1 2 5 4 6 7
7 3 1 2 5 7 4 2 3 6 7 4 1 3 5
4 6 7 3 6 1 7 5 3 6 7 2
C7 + 6(E5) C7 + 6(I5) C7 + 6(S5)

Figure 8.4. The six solution boards with the poly-


hex decomposition displayed below

The other case is to use the polyhex C7 together with six of E5, I5, and/or S5.
It is not hard to see that these can only work out using C7 plus six copies of the
same polyhex, leading to another three unique solutions given in the second row
of Figure 8.4.
The six Septoku solutions in Figure 8.4 satisfy some interesting symmetry re-
lations. We define (𝑅𝑜𝑡) as the transformation which rotates the board clockwise
60∘ . We use standard notation to represent a permutation as a product of cycles.
The cycle (14) describes the permutation which sends 1 ↦ 4, 4 ↦ 1, and leaves
all other numbers alone.
We can easily verify that all solution boards 𝐵 in Figure 8.4 satisfy
𝐵(𝑅𝑜𝑡)3 (14)(25)(36) = 𝐵. (8.1)
The boards in the second row of Figure 8.4 satisfy an even stricter relation
𝐵(𝑅𝑜𝑡)(123456) = 𝐵. (8.2)
The lower-left board in Figure 8.4 has an additional symmetry: all seven
numbers are present in every possible circle on the board! This includes the seven
Septoku circles plus twelve additional circles centered at all remaining interior
cells. As we shall see, this “all equilateral” pattern can be extended periodically
to infinity.
If we take the six Septoku boards, and apply any of twelve symmetry trans-
formations followed by any of 7! permutations, we will generate 6(12)(7! ) valid
George I. Bell 69

Septoku boards. However, not all of these boards are distinct, due to the symme-
try equations (8.1) and (8.2). For any board in the top row of Figure 8.4, the total
number of boards is reduced by a factor of 2 and, in the bottom row, by a factor of
6. This reduces the total number of distinct boards to 3(12/2+12/6)(7! ) = 24×7!.

Theorem 8.5. For a Septoku puzzle with a unique solution, the minimum number
of givens is 6.

Proof. Clearly, the answer cannot be less than 6. If it was, there must be two of
the seven numbers not even among the givens. If there is one solution, a different
one can be obtained by swapping these two numbers.
To show the answer is 6, we need only find a puzzle with six givens and a
unique solution. We wrote a program that checks puzzles for a unique solution
by matching against all possible symmetry transformations and permutations of
the six possible boards. We found hundreds of six given puzzles with unique
solutions; two are shown in Figure 8.5.

Figure 8.5. Two puzzles with six givens and


unique solutions, and a puzzle with three givens and
a unique solution up to a permutation

To narrow the solution down to one of the six types shown in Figure 8.4,
only three givens are required. For example, note that the “equilateral” pattern
E5 appears in only one solution. Thus, if we use the three givens on the right
board in Figure 8.5, the solution can only be the “all equilateral” board on the
lower left of Figure 8.4, or any permutation of it which fixes 1.
The symmetry relations in equation (8.1) generate a useful algorithm for
solving Septoku boards.

Theorem 8.6. In a valid Septoku board, the seven symbols can be partitioned into
three pairs and one unpaired symbol which is the value of the central cell 19. Let
70 Chapter 8. The Mathematics of Septoku

𝑥 and 𝑦 be any two cells that map to each other under 180∘ rotation of the board.
Then either
(1) 𝑥 and 𝑦 have different values taken from one of the three pairs, or
(2) 𝑥 and 𝑦 both have the value of the central cell (clearly, this is only possible if 𝑥
and 𝑦 are not in the same row).

Proof. For the six solutions in Figure 8.4, Theorem 8.6 is just a restatement of
equation (8.1). Since any solution is a symmetry transformation plus permuta-
tion of one of these, all solutions satisfy Theorem 8.6.
Once we determine the pairings, Theorem 8.6 is very useful in solving Sep-
toku puzzles—because it says that once we determine a number in a certain cell,
we can immediately fill out the cell diametrically opposite (mapped by 180∘ ro-
tation).
With these additional insights, the reader may wish to revisit the puzzles in
Figure 8.2. For example, in the “hard” puzzle, one Theorem 8.6 pair is {3, 4}, and
this implies that cell 12 must contain a 3. The reader should find that completing
this puzzle is not difficult using Theorem 8.6. One puzzle that remains difficult
is that in Figure 8.5(b). In this puzzle no pairings can be determined from the
starting givens.
The last theorem shows that the requirements on the central circle 19 can be
removed and the puzzle is unchanged.

Theorem 8.7. Consider Septoku, but drop the requirement that the symbols in the
center circle 19 be distinct. There are no solutions to the puzzle where the cells in the
center circle are not distinct.

Proof. Suppose a solution exists with two symbols the same in circle 19. Because
the rows must be distinct, the central number cannot be the duplicate, so without
loss of generality assume that the symbol 1 appears in cells 13 and 26. But circles
17 and 21 must both contain 1’s, and these can only be on row 16 → 22. There
cannot be two 1’s along this row, so no solution is possible.

8.2 Larger Boards


When analyzing Septoku, I noticed that some Septoku solutions have the prop-
erty that the solution can be extended off the board, while holding to a natural
extension of the rules. We can extend two opposite edges of the board to create a
49-cell rhombus Septoku board in Figure 8.6.
The rhombus (or diamond) board has two sets of rows which all have seven
cells, and another set of rows which have two to seven cells. On this board, ev-
ery symbol must appear exactly seven times. All the Figure 8.3 patterns can be
George I. Bell 71

Figure 8.6. The two valid rhombus Septoku boards

extended to this board except for U6 and I5, and of the six solutions in Figure 8.4
only two do not involve U6 or I5; therefore, there are only two valid rhombus
Septoku boards (Figure 8.6).
The “all equilateral” solution in Figure 8.6 has additional symmetries in that
every circle contains all seven numbers. Extended periodically, this solution shows
that any Septoku board, no matter how large or how the circles are arranged, has
at least one valid board.
If we interpret each number as a color, the “all equilateral” solution gives a
7-coloring of the plane which is well-known to graph theorists. If the diameter
of each hexagon is just under one, this coloring has the remarkable property that
any two points in the plane a distance exactly one apart have different colors. This
coloring provides an upper bound for the so-called Hadwiger–Nelson problem,
which asks for the minimum number of colors for which such a coloring of the
plane is possible. As shown in 1961, the minimum number of colors required lies
between 4 and 7 (inclusive) (Gardner, 1983; Ogilvy, 1972). These bounds have
not been reduced 50 years later, and the Hadwiger–Nelson problem remains a
significant unsolved problem in combinatorial geometry (Demaine et al., 2016).
Another possible variation is the 73-cell star Septoku board (Figure 8.7). On
this board, some of the rows have more than seven cells. We therefore modify the
rules to specify that the symbols in any connected subset of a row with seven or
fewer cells must contain distinct symbols. There are only two valid star Septoku
boards.
Not surprisingly, it is easy to create many puzzles in rhombus or star Septoku
with six givens that have unique solutions. An example of one such puzzle is
shown in Figure 8.7.
72 Chapter 8. The Mathematics of Septoku

Figure 8.7. A valid star Septoku board, a puzzle


with six givens and a unique solution

Figure 8.8. A valid flower Septoku board, a puzzle


with six givens and a unique solution
George I. Bell 73

In all the board types discussed so far, the circular regions overlap. It is pos-
sible to create a board on a hexagonal grid where the circular regions do not over-
lap, more reminiscent of ordinary Sudoku. Figure 8.8 shows a flower Septoku
board, which has 49 cells and 34 regions.
Since the circular regions no longer overlap, one might guess that flower
Septoku is quite different from normal Septoku. However, a similar analysis re-
veals that there are only three different flower Septoku boards (up to a symme-
try transformation and permutation). These three solutions also satisfy Theo-
rem 8.6—so despite the change in geometry, solutions to flower Septoku have
the same symmetry properties as in regular Septoku.

8.3 Conclusions
Although Septoku appears similar to Sudoku, we have found that it has only six
fundamentally different solution boards. We have shown that a Septoku puzzle
must have at least six givens to have a unique solution, and we have devised puz-
zles with six givens that can be quite difficult to solve by hand. Theorems 8.1, 8.2,
and especially 8.6 are useful for solving Septoku puzzles.
The main difference between Sudoku and Septoku are the extra constraints
imposed by an additional set of parallel rows in a hexagonal grid. In any variation
of Septoku we have considered, these additional constraints have resulted in a
relatively small number of solutions.
How might we modify the rules of Septoku so that there are more than six
solution boards? One way is to reduce the number of regions, but we have shown
that removing the central region does not change the puzzle. Another option
is to allow eight symbols and keep all the regions the same. If we do this, all
our theorems are no longer valid, and many more solution boards are possible.
However, it is now quite difficult to specify a unique solution to a puzzle using a
reasonable number of givens. For example, it is not hard to find an eight symbol
Septoku puzzle with 36 givens and only one open cell which does not have a
unique solution!

8.4 Acknowledgments
I thank Bruce Oberg for inventing this fascinating puzzle and Ed Pegg for point-
ing out the connection to the Hadwiger–Nelson problem. Thanks to Wei-Hwa
Huang for sharing his analysis of Septoku and his idea that the two central pat-
terns were the key to the analysis.
74 Chapter 8. The Mathematics of Septoku

8.5 Solutions
See Figure 8.9 for solutions to the Septoku puzzles in Figures 8.1, 8.2, and 8.5.
The unique solution to the star Septoku problem in Figure 8.7(b) can be found
by applying the permutation (16543) to the solution in Figure 8.7(a). For the
flower Septoku problem in Figure 8.8(b), simply label each circular region with
the same pattern, that in the center circle of the board in Figure 8.8(a).

4 7 1 2
2 6 5 3 7
7 1 3 4 6 5
3 4 6 5 2 7 1
5 2 7 1 3 4
4 1 5 2 6
6 3 4 7
Figure 8.1(a)

5 7 4 6 1 7 5 3
6 3 2 1 7 2 6 4 1 7
7 4 1 5 3 2 7 5 3 2 6 4
2 5 3 4 6 7 1 6 4 1 7 5 3 2
1 6 7 2 4 5 3 2 6 4 1 7
5 2 1 6 3 7 5 3 2 6
3 4 5 7 4 1 7 5
Figure 8.2(a), ‘G’ Figure 8.2(b), ‘7’

5 2 1 6 5 7 1 3
3 6 4 7 2 1 2 6 5 4
6 1 7 5 3 4 6 3 4 2 7 5
7 4 2 3 6 5 1 2 4 5 7 1 3 6
5 3 4 1 7 2 1 7 6 3 4 2
6 1 5 2 3 3 1 2 6 5
2 7 6 4 4 5 7 1
Figure 8.5(a) Figure 8.5(b)

Figure 8.9. Unique solutions for problems in fig-


ures as indicated.
George I. Bell 75

Further Reading
E. D. Demaine, J. Mitchell, and J. O’Rourke (2016). Open Problems Project; see
problem 57, Chromatic Number of the Plane. http://maven.smith.edu/
~orourke/TOPP/.
M. Gardner (1983). Wheels, life, and other mathematical amusements. W. H.
Freeman, New York.
J. J. Light (2009). Tri-doku. Éditions Bravo!, Montreal.
B. Oberg (2007). G4G7 Exchange book, volume 2, see the chapter, Septoku,
pp. 153–160. Gathering 4 Gardner, Atlanta, GA.
C. S. Ogilvy (1972). Tomorrow’s math; unsolved problems for the amateur. Oxford
University Press, New York.
T. Snyder (2008). Battleship Sudoku. Sterling.
T. Snyder and W.-H. Huang (2009). Mutant Sudoku. Puzzlewright.
Part 3

History
Our third section presents the story of how two specific problems developed
and came to be solved. The first paper discusses the search for God’s number on
Rubik’s Cube over the past 30 years, and the second goes much further back in
describing the history of Nim and its variants.
9
Thirty Years
of Computer Cubing:
The Search for God’s Number
Tomas Rokicki

9.1 Introduction
In 1979, in the first edition of his Notes on Rubik’s Magic Cube (Singmaster, 1980),
David Singmaster asserted that every position of Rubik’s Cube can be solved in
twenty moves or less. It would be more than 30 years until this was shown to be
true, with many distinct individual contributions. This is a chronological story
of the insights and breakthroughs that culminated in the proof of Singmaster’s
assertion.
Rubik’s Cube is a great example of Martin Gardner’s philosophy of teaching
math through puzzles. Right at this moment there are thousands of teenagers
who understand the mathematical concepts of commutators, conjugation, per-
mutation parity, groups, and nested subgroups solely through their exposure to
Rubik’s Cube.
Has the cube been solved? Over 3,000 individuals can solve it in less than 20
seconds, many with only one hand. Robots have been built to solve it; one can do
it in less than four seconds. Underwater solving is commonplace, and over 1,000
individuals have been able to solve it blindfolded. Solution books have been sold

79
80 Chapter 9. Thirty Years of Computer Cubing

by the millions, and larger versions of the cube, up to 7 × 7 × 7, are popular.


Certainly, we understand this puzzle at this point.
But much remains unknown in the mathematics of the cube. The funda-
mental problem, determining just how scrambled a cube can be, is intuitively in-
teresting. When using a human algorithm to solve the cube (one that is intended
to be used manually, rather than in a computer search), it is fairly clear that the
solution we construct uses too many moves. Just like a short proof is valued over
a long one, a short solution for a given position is more interesting than a long
one. It is hard to avoid asking just how short a solution for a particular position
can be, and then further, what positions require the longest solution sequences,
and how long those sequences must be.
Every speedsolver uses, and every “how to solve the cube” book contains,
an algorithm for solving the cube. These algorithms all depend on observation
of specific portions of the cube state, followed by specific move sequences based
on that observation. Typical algorithms are short and can be expressed with a
few pages of notes. Some advanced algorithms have extensive tables and move
sequences with perhaps a few hundred alternatives. But in general these algo-
rithms lead to move sequences that are far from optimal; typical algorithms may
require 50 to 80 moves or more. In general, algorithms that end up requiring
fewer moves, and thus can be executed more rapidly, are more complex, requir-
ing longer tables and more alternatives. The limit of this is known as God’s Al-
gorithm—for every position, a move sequence is given (or calculated) that is of
minimal possible length (optimal). God’s Number is just the length of the longest
sequence that is optimal—the length of the longest sequence that will ever be
returned by God’s Algorithm.
With modern computers, God’s Algorithm can be implemented by a com-
puter program that uses a search to find optimal solutions. With modern desk-
top computers, typical positions are solved optimally in minutes; seconds, with
machines having a significant amount of memory. But having access to God’s
Algorithm does not immediately provide us with God’s Number; we still need
to figure out what position is the hardest to solve and prove it is the hardest to
solve. This was finally accomplished (for the half-turn metric) using about 35
CPU years at Google in 2010—the final result was twenty moves (Rokicki et al.,
2013).
The history of progress towards God’s Number can be divided into three eras
separated by long periods of calm. The first era was intense but short, corre-
sponding to the initial cube craze from 1979 through 1982. The second era, from
1989 to 1998, was initiated by availability of 16-bit home computers, leading to
new ideas and algorithms. Finally, the third era, from 2003 to 2010, was initiated
by the growing popularity of the Web, which lead to a renewed interest in speed
cubing and computer cubing.
Tomas Rokicki 81

For the most part, progress was characterized primarily by competition and
cooperation among a small group of people. As is common with recreational
mathematics, most work was unfunded, done with spare time and spare cycles,
and driven mostly by curiosity and mere challenge.
In cube mathematics, the primary metric is the definition of what consti-
tutes a move. There are two camps; the less common is the quarter-turn metric
(QTM), where only a 90 degree turn of a face is considered a move, and where
a 180 degree twist, or half-twist, is considered two moves. The more common is
the half-turn metric (HTM), where both the quarter-twist and the half-twist are
considered a single move. There are other fringe metrics, but these are the two
metrics we will concern ourselves with. Nor will we discuss other mathematical
or computational aspects of the cube, and we focus instead on calculations for
God’s Number and God’s Algorithm.
We define progress in the search for God’s Number by the achievement of
specific milestones. The first and most essential type of progress is when the
upper bound is decreased—determination of an algorithm that is guaranteed to
solve the cube in fewer moves than previously known, or a proof in which no
positions require more than that many moves. The second type of progress is
when the lower bound is increased—usually shown by determination of a posi-
tion that requires at least that many moves. When those upper and lower bounds
meet, they meet at God’s Number. The third is the determination of the precise
count of positions at a particular distance from solved (a position’s distance from
solved is the minimum number of moves required to solve it). Table 9.1 gives the
key results in the half-turn metric; Table 9.2, the key results in the quarter-turn
metric.
One might think that progress of all three types might go hand-in-hand, that
we would typically not know God’s Number until we also had position counts at
each distance. This is typically true for smaller puzzles, and indeed it may be the
best we can do for some puzzles. But at least for Rubik’s Cube, in the half-turn
metric, God’s Number was proven to be 20 while the count of positions at depth
16 and greater are still unknown.
Almost all of the milestones concerning us were reported in two forums. The
first is the original cube-lovers mailing list (Rokicki, 2010b), which began in
July 1980 and ran until January 2000; references in this paper to that list will be
given with the CL prefix and a date, as in CL-12-Jul-80. Archives of cube-lovers
can be found in various places on the Web. The second key source of results is
the “Domain of the Cube”, a forum for the cube created by Mark Longridge in
June 2004. References to postings will be given with a DC prefix and the post-
ing number, as in DC-23; the URL http://forum.cubeman.org/drupal/?q=
node/view/23 will retrieve the posting. References from these two sources are
not given individual bibliography entries. Other sources include back issues of
82 Chapter 9. Thirty Years of Computer Cubing

Table 9.1. Chronology of God’s Number calcula-


tions, half-turn metric. An entry in the Count col-
umn indicates computation of a distance count at
that distance. An entry in the Lower column indi-
cates an increase in the lower bound for God’s Num-
ber. An entry in the Upper column indicates a de-
crease in the upper bound for God’s Number.

Date Count Lower Upper Reference


30 Nov 1979 17 DS (Singmaster, 1980)
30 Nov 1979 85 MT (Singmaster, 1980)
16 Jan 1980 18 DS (Singmaster, 1980)
12 Jan 1980 52 MT (Singmaster, 1980)
15 Dec 1989 44 HK2 CFF
15 Dec 1990 42 HK2 (Kloosterman, 1990)
23 May 1992 39 MR CL-23-May-92
28 May 1992 37 DW CL-28-May-92
19 Jul 1994 7 JB CL-19-Jul-94
7 Jan 1995 29 MR CL-07-Jan-95
18 Jan 1995 20 MR CL-18-Jan-95
12 Jan 1998 9 JB CL-12-Jan-98
10 Jul 1998 10 JB CL-10-Jul-98
22 Dec 2005 28 SR DC-37
1 Apr 2006 27 SR DC-53
30 Nov 2006 11 JB DC-68
31 May 2007 26 DK, GC (Kunkle and Cooperman, 2007)
20 Mar 2008 25 TR DC-112
29 Apr 2008 23 TR DC-117
12 Aug 2008 22 TR DC-121
23 Jun 2009 12 TR DC-144
15 Jul 2009 13 TR DC-146
23 Jun 2010 14 TS DC-191
29 Jul 2010 15 TR, HK, JD, MD DC-197
8 Aug 2010 20 TR, HK, JD, MD DC-199

Cubism for Fun, a few academic papers, and David Singmaster’s Notes on Rubik’s
Magic Cube. In the tables, names will be abbreviated according to the key in Table
9.3.
This is not a technical paper. We will provide results and a very brief descrip-
tion of some techniques, but the actual details are left to the references.
Tomas Rokicki 83

Table 9.2. Chronology of God’s Number calcula-


tions, quarter-turn metric. An entry in the Count
column indicates computation of a distance count
at that distance. An entry in the Lower column indi-
cates an increase in the lower bound for God’s Num-
ber. An entry in the Upper column indicates a de-
crease in the upper bound for God’s Number.

Date Count Lower Upper Reference


30 Nov 1979 19 DS (Singmaster, 1980)
9 Jan 1981 21 DH CL-09-Jan-81
22 Mar 1981 5 DH CL-22-Mar-81
14 Aug 1981 6 DH CL-14-Aug-81
7 Dec 1981 7 DH CL-07-Dec-81
23 May 1992 56 MR CL-23-May-92
18 Jul 1994 8 JB CL-18-Jul-94
12 Sep 1994 10 JB CL-12-Sep-94
7 Jan 1995 42 MR CL-07-Jan-95
20 Jan 1995 22 MR CL-20-Jan-95
4 Feb 1995 11 JB CL-04-Feb-95
2 Aug 1998 26 MR CL-02-Aug-98
26 Oct 1998 12 JB CL-26-Oct-98
9 Jul 2005 13 JB DC-23
14 Nov 2005 40 SR DC-33
26 Nov 2005 38 BN DC-34
14 Jan 2006 36 SR DC-39
22 Mar 2006 35 SR DC-50
2 Jul 2007 34 SR DC-92
14 Jan 2009 32 TR DC-131
25 Jan 2009 31 TR DC-134
19 Feb 2009 30 TR DC-138
15 Jun 2009 29 TR DC-143
24 Jun 2009 14 TR DC-145
19 Sep 2009 15 TR DC-153
9 Jul 2010 16 TS DC-194
14 Jul 2010 17 TS DC-195
14 Jul 2010 17 TS DC-195
19 Jul 2014 18 TR, MD DC-535
4 Sep 2014 26 TR, MD DC-537
84 Chapter 9. Thirty Years of Computer Cubing

Table 9.3. The major participants in God’s Number


computations. The first column is the abbreviation
used in the chronology tables.

JB Jerry Bryan
GC Gene Cooperman
JD John Dethridge
MD Morley Davidson
DH Dan Hoey
DK Daniel Kunkle
HK Herbert Kociemba
HK2 Hans Kloosterman
ML Mark Longridge
BN Bruce Norskog
MR Michael Reid
SR Silviu Radu
TR Tomas Rokicki
DS David Singmaster
TS Thomas Scheunemann
MT Morwen Thistlethwaite
DW Dik Winter
JW John Welborn

9.2 The Craze: 1979 to 1982


The initial cube craze was intense but also short-lived; first available in the United
States in May 1980, the cube disappeared from retail shelves by the mid-1980s.
The initial world championship for speedsolving was held in June 1982; there
would not be another for more than twenty years.
Interest in the mathematics of the cube followed this same pattern—intense
interest for a few years, followed by a long period of calm. Between 1979 and
1982 the foundations of cube mathematics were laid. David Singmaster’s Notes
on Rubik’s Magic Cube, which first appeared in February of 1979 (preceding the
availability of the cube itself in the United States by some fifteen months), laid
the basis for mathematics of the cube. He developed a common language for
talking about moves of the cube, introduced many to group theory with the cube
as exemplar, and calculated and collected many interesting puzzles and results
about the cube. He adopted the half-turn metric throughout. He showed, for
instance, that there are 43,252,003,274,489,856,000 reachable positions.
Tomas Rokicki 85

In his first edition, he showed a lower bound by considering a geometric


series. In the half-turn metric, it is never useful to turn the same face on con-
secutive moves, so his geometric series for sequences of a particular length starts
1, 18, 18 ⋅ 15, 18 ⋅ 152 , . . . , which has a sum of 1 + 18(15𝑛 − 1)/14. Solving this
for 𝑛 from the number of reachable positions gives 𝑛 = 16.6, so there must be
positions that take 17 moves. In the quarter-turn metric, we cannot use such a
simple same-face simplification, so the geometric sequence 1, 12, 122 , . . . , which
has a sum of (12𝑛+1 − 1)/11, gives a lower bound in the quarter-turn metric of 19.
In the third edition, Singmaster credits O’Hara and Thistlethwaite for an im-
provement in this calculation. Some moves on the cube commute—they can be
done in any order with the same effect. So for instance, a half-turn on the up
face and a clockwise quarter-turn on the down face can be done in either or-
der. We can define a set of canonical sequences by defining a preferred order for
such commuting moves and by rejecting sequences that do not obey such rules.
The count of such sequences of a given length much more closely matches the
count of positions at that distance. This result directly permits efficiently search-
ing the Rubik’s Cube space. This does not apply as well to other state-space
explorations, but for Rubik’s Cube it works very well. In the half-turn metric,
through depth 15 (the greatest depth less than 21 for which we know the exact
count of positions), there are 103,697,388,221,736,960 canonical sequences and
91,365,146,187,124,313 distinct positions, for a ratio of only 1.135; see Table 9.4.
In the quarter-turn metric, through depth 18 (the greatest depth less than 30 for
which we know the exact count of positions), there are 404,768,967,341,615,520
canonical sequences and 368,071,526,203,620,348 distinct positions, a ratio of
only 1.100; see Table 9.5.
This recurrence provided an improvement to the lower bound on God’s Num-
ber: in the half-turn metric the bound rises to 18, and in the quarter-turn metric
the bound rises to 21. These lower bounds would remain unchanged until 1995,
when Kociemba’s two-phase algorithm enabled deep computer searches of spe-
cific positions.
Upper bounds were more plentiful—virtually any folk algorithm could be
evaluated to compute an upper bound on the diameter. In Singmaster’s Novem-
ber 1979 third addendum, he describes Thistlethwaite’s algorithm to solve the
cube in 85 or fewer moves in the half-turn metric. In the fourth addendum, this
is reduced to 80 moves. The fifth addendum, appearing sometime in 1980, de-
scribes Thistlethwaite’s famous 52-move solution (Thistlethwaite, 1981) based on
nested subgroups—this would remain the upper bound for the half-turn metric
for nearly a decade. No explicit upper bound for the quarter-turn metric (other
than the trivial doubling of the upper bound of the half-turn metric) would be
published until 1992.
86 Chapter 9. Thirty Years of Computer Cubing

Table 9.4. The count of canonical sequences of


length 𝑛 and positions at distance 𝑛 in the half-turn
metric. Can you extend this table?

𝑑 Canonical Sequences Positions


0 1 1
1 18 18
2 243 243
3 3,240 3,240
4 43,254 43,239
5 577,368 574,908
6 7,706,988 7,618,438
7 102,876,480 100,803,036
8 1,373,243,544 1,332,343,288
9 18,330,699,168 17,596,479,795
10 244,686,773,808 232,248,063,316
11 3,266,193,870,720 3,063,288,809,012
12 43,598,688,377,184 40,374,425,656,248
13 581,975,750,199,168 531,653,418,284,628
14 7,768,485,393,179,328 6,989,320,578,825,358
15 103,697,388,221,736,960 91,365,146,187,124,313

Home computers at this time were 8-bit machines with typically 16K to 64K
of RAM—large enough to implement simple folk algorithms, but too slow and
resource-constrained to do any sort of large search. But schools and research
institutions sometimes made larger machines available for research. On January
9, 1981, Dan Hoey published a table with a count of distinct positions at depths 0
through 4 in the quarter-turn metric (1, 12, 114, 1,068, 10,011). All of these agree
exactly with the count of canonical sequences. Between March and December of
1981, Dan Hoey calculated the number of positions at depths 5, 6, and 7 of the
quarter turn metric: depth 5 has 93,840 positions, depth 6 has 878,880 positions,
and depth 7 has 8,221,632 positions. These would be the only published progress
on depth counts for 13 years, until Jerry Bryan took up the challenge in 1994.
Interest in the cube peaked in the early 1980s; the first world championship
was held in 1982. But by 1983 it was getting difficult to find the cube in stores.
No world championship was held in 1983, or for decades afterwards. Interest
in mathematical investigation of the cube mirrored this decline, and no progress
was reported for years.
Tomas Rokicki 87

Table 9.5. The count of canonical sequences of


length 𝑛, positions at distance 𝑛 in the quarter-turn
metric. Can you extend this table?

𝑑 Canonical Sequences Positions


0 1 1
1 12 12
2 114 114
3 1,068 1,068
4 10,011 10,011
5 93,840 93,840
6 879,624 878,880
7 8,245,296 8,221,632
8 77,288,598 76,843,595
9 724,477,008 717,789,576
10 6,791,000,856 6,701,836,858
11 63,656,530,320 62,549,615,248
12 596,694,646,092 583,570,100,997
13 5,593,212,493,440 5,442,351,625,028
14 52,428,869,944,896 50,729,620,202,582
15 491,450,379,709,824 472,495,678,811,004
16 4,606,688,566,257,048 4,393,570,406,220,123
17 43,181,530,471,120,320 40,648,181,519,827,392
18 404,768,967,341,615,520 368,071,526,203,620,348

9.3 Rise of the Machines: 1989 through 1998


In 1989, the cube started reappearing in Europe, and further progress on God’s
Number was reported in Cubism for Fun, when Hans Kloosterman reduced
the upper bound first to 44 in December 1989 and then to 42 in December 1990
(Kloosterman, 1990). The latter value was achieved by the same approach as
Thistlethwaite, but using a different chain of subgroups. These results were sub-
stantial improvements over Thistlethwaite’s result of 52. This was the start of a
deluge of results, almost all from combining computer explorations and careful
hand analysis. The computer explorations would probably not have been practi-
cal with the memory commonly available in machines before this era.
The year 1992 was a watershed year for computer cubing, with Herbert Ko-
ciemba’s astonishing revelation of a technique and computer program that could
solve positions in only 21 moves in a matter of minutes (Kloosterman, 1990)!
This was the first practical program for finding short solutions to arbitrary po-
sitions. It ran on a common Atari ST with an 8MHz 68000 processor and only
88 Chapter 9. Thirty Years of Computer Cubing

one megabyte of RAM. His four-page article in Cubism for Fun spurred investi-
gations and interest in God’s Number over the coming months. This algorithm,
called the two-phase algorithm, combined two major ideas: he used a subgroup
chain of length two, rather than the four used by Thistlethwaite, and rather than
stopping once the first solution is found, he continued searching for shorter solu-
tions. Previous algorithms found solutions that required many more moves than
the optimal solution; this was the first algorithm that found solutions very close
to the optimal length. This algorithm still forms the heart of the most popular
cube solving program, Cube Explorer, available from his website.
Dik Winter quickly implemented his own version of the algorithm and com-
plained that the program “ran too fast”; it took longer to enter the position than
to get solutions! He extended Kociemba’s ideas to better use the 32 megabytes of
memory on his machine. His version of the program found solutions of twenty
moves or less for all positions he tried.
Just a few days after Dik Winter posted his results, Mike Reid posted a new
upper bound on God’s Number of 39, found by analysis of a new three-stage sub-
group chain; the size of the state spaces for the three steps were 253 thousand, 16
million, and 11 million states. It is probable he used a machine with at least 32
megabytes of memory to get these results.
Not to be outdone, just a few days later Dik Winter posted a full analysis of
phase one of Kociemba’s two-phase algorithm, showing that phase one could al-
ways be solved in twelve moves or less. A total of two billion states were analyzed;
he reduced this to about 170 million by considering symmetry. Because so many
states did not fit in his computer’s memory, he split the state space among a farm
of workstations, requiring about 3000 computer hours total. In combination with
Kloosterman’s earlier results, he thus lowered the upper bound on God’s Num-
ber to 37. In less than two weeks, the upper bound had dropped twice, first from
42 to 39, then from 39 to 37, by two different researchers. It would remain at 37
for a few years.
A few months later, Dik Winter published an analysis of 9,000 random po-
sitions, and showed that he could solve all of them in 20 moves or less in about
ten minutes each, but none required 21 or more moves. He used his implemen-
tation of Kociemba’s near-optimal solver, so the actual distance of each position
was not calculated, just that it could be solved in 20 or fewer moves. This spurred
discussion on whether distance-21 or 22 positions exist; none are known, but the
work done so far does not prove they cannot exist.
In 1994, Jerry Bryan extended the table of position counts known at a given
distance. In July he pushed the quarter-turn metric out to distance 8 (76,843,595)
and the half-turn metric out to distance 7 (100,803,036). His approach was a
depth-first search using external memory (disk), with sorting and merging ap-
plied to the disk files. In September he improved his algorithm to take symmetry
Tomas Rokicki 89

Figure 9.1. Position (a) is superflip, the first posi-


tion proven to take 20 moves in the half-turn met-
ric. Position (b) is superflip composed with four-
spot, the first position shown to take 26 moves in
the quarter-turn metric.

into account, and was able to push the quarter-turn metric two more levels, to
distance 9 (717,789,576) and distance 10 (6,701,836,858), using about the same
amount of disk space and effort as before.
The new results did not stop there. In January 1995 Michael Reid fully ana-
lyzed both phases of Kociemba’s two-phase algorithm, in both the half-turn and
the quarter-turn metric. Phase two has nearly 20 billion states. He reduced this
by both symmetry (16-way) and inversion in order to fit the state space into a
256-megabyte DEC 3000 alpha 700. This work set new upper bounds on God’s
Number in both the quarter-turn metric (42) and the half-turn metric (29), both
significant reductions from the previous 56 and 37, respectively.
Reid was not content to just dramatically reduce the upper bound that month.
Less than two weeks later, he posted a proof that the position “superflip” (see
Figure 9.1(a)), which is the same as solved except all edges are flipped, cannot be
solved in fewer than 20 moves in the half-turn metric. This increased the lower
bound on God’s Number in the half-turn metric from 18 to 20; no position harder
than this would ever be found. A few days later he proved that the position re-
quires at least 22 moves in the quarter-turn metric, raising the lower bound in
the quarter-turn metric to 22.
Just one month later, in February 1995, Bryan successfully pushed the quarter-
turn distance calculations out to distance 11 (62,549,615,248).
Things were quiet then for about two years, until in May of 1997, Richard
Korf published results about the first practical optimal solver for the cube (Korf,
1997). This program, using the half-turn metric, required typically a day per po-
sition. Korf reported ten random positions solved, one in 16 moves, three in 17,
and six in 18. This was the first estimate at a distance distribution for the cube,
and first real evidence that most positions take 18 half-turn moves to solve.
90 Chapter 9. Thirty Years of Computer Cubing

Michael Reid wrote his own version of Korf’s optimal solver in July of 1997.
Unlike Korf’s use of pattern databases based on specific cube subsets, he used Ko-
ciemba’s phase one, applied in three different orientations. He used 67-megabyte
pruning tables on a 128-megabyte computer. Within a month, guided by intu-
ition and using his new optimal solver, he was able to extend the set of known
distance-20 positions by 3, adding superfliptwist, superfliptwist composed with
pons asinorum, and superfliptwist composed with six-H’s. He found these by
solving the most symmetric positions but found no additional positions that re-
quired more than 19 moves to solve.
In September of 1997, Herbert Kociemba published a closed-form solution
to the count of canonical sequences of length 𝑛. This formula, with 𝑟 = √6, is
((3 + 𝑟)(6 + 3𝑟)𝑛 + (3 − 𝑟)(6 − 3𝑟)𝑛 )/4.
He pointed out the asymptotic branching factor of 6 + 3𝑟 = 13.348469, which is
very close to Bryan’s observed branching factor. Indeed, the iterated depth-first
search used by both Kociemba and Korf works so well on Rubik’s Cube precisely
because this close correspondence between the count of canonical sequences of
length 𝑛 and positions at distance 𝑛 holds for such large 𝑛 for Rubik’s Cube.
In October 1997, Keith H. Randall published his investigations into optimal
solutions for random cubes in the quarter-turn metric. His program was capable
of a complete 22-ply search in about 24 hours on an 8-processor Sun computer,
probably the fastest program at the time. The Cayley graph for the quarter-turn
metric is bipartite, so exactly half the positions are at odd distance and half at
even distance. He solved 112 random odd cubes, and found 20 to be depth 19
and 92 to be depth 21; he also solved 57 even cubes, and found 41 at depth 20 and
16 at depth 22. Combining these results, he showed the distance distribution in
the quarter-turn metric is close to

𝑑 KR 1997 TR 2011
18 0.0% 0.8%
19 8.9% 6.9%
20 36.0% 33.1%
21 41.1% 43.0%
22 14.0% 16.1%

The third column shows modern results from a survey of three million random
positions. He pointed out that distance-23 positions were so rare that none were
found in his survey of 112 random odd positions, and thus certainly distance-24
positions were even more rare. Based on this, he surmises that God’s Number in
the quarter-turn metric may be 24.
Tomas Rokicki 91

At about this time Bryan was experimenting with Shamir’s algorithm for lex-
icographical breadth-first state-space search that incrementally generated posi-
tions at distance 2𝑛 from a tree of positions at distance 𝑛, thus requiring much less
storage for a given distance. Lexicographical generation permits duplicate elim-
ination on the fly, eliminating the need to store a representation of every posi-
tion. This algorithm had been discussed on the cube-lovers list back in 1987, and
David Moews used it to confirm some results of Michael Reid in January of 1995.
First, Bryan confirmed the results of his earlier breadth-first search programs
for the quarter-turn metric through distance 11. Next, he used this technique
to extend his face-turn metric distance calculations to depths 8 (1,332,343,288)
and 9 (17,596,479,795), and to extend his quarter-turn results out to depth 12
(583,570,100,997). All these numbers were obtained using a 48-way symmetry
reduction.
The most amazing result of 1998, however, belonged to Michael Reid. In
August, he reported finding a position that required 26 moves in the quarter-turn
metric, thus raising the lower bound on God’s Number in that metric to 26 (see
Figure 9.1(b)). This result is made more interesting by recent results indicating
that this is the only distance-26 position in the whole cube space and, further,
that the only distance-25 positions are the immediate neighbors of this position.
Computer cubing took another break at this point for a while. The primary
reason was probably the death of the venerable cube-lovers mailing list. The last
message was posted in early 2000. The archives of this mailing list still make
fascinating reading for anyone interested in Rubik’s Cube.

9.4 The Web Era: 2003 through 2010


The cube made a major resurgence in 2003. Cubes were once again available in
stores, a speedsolving group was established and gaining popularity on Yahoo
groups, and in 2003, after a break of twenty years, a second world championship
was held.
Through this point I had not been active in the computer cubing community.
I had written a few cube programs, including (back in 1982) a solver that used
my own folk algorithm for the TRS-80 color computer, but such programs were
commonplace. In 2001 I purchased a home machine with 768 megabytes of RAM
(uncommon at the time) for some other research, and I decided to see what I
could do with it on cube explorations.
In June of 2003, I posted to the Yahoo speedsolving group some distance
statistics in the half-turn metric I had computed for 5,000 positions (my program
did about 100 positions a day). That distribution was
92 Chapter 9. Thirty Years of Computer Cubing

𝑑 TR 2003 TR 2011
15 0.1% 0.2%
16 2.1% 2.7%
17 25.6% 26.7%
18 68.3% 67.1%
19 4.0% 3.4%

Not a single distance-20 position had been found in months of searching through
random positions. Indeed, in the survey of three million random positions I did
in 2011, not a single distance-20 position was found.
Later, in January of 2004, I published two tables showing that all the edges
of the cube (ignoring the corners, but taking into account the centers) could be
solved in 18 moves in the quarter-turn metric, and 14 moves in the half-turn met-
ric. These tables were posted on the Yahoo speedsolving group. This exploration
represents nearly a trillion total positions and, with additional work by others,
would lead to further reductions in the upper bound on God’s Number in both
metrics.
What really fueled the resurgence of computer cubing was when Mark Lon-
gridge created a forum on the Web called “Domain of the Cube” in June 2004.
This was (and is!) a reincarnation of the original cube-lovers mailing list, but as
a modern Web forum. Discussions started very quickly, and in July 2005, Jerry
Bryan posted his results extending the distance table in the quarter-turn metric
to 13 (5,442,351,625,028). This result was calculated in four months on a 2.8GHz
Pentium 4. But this result was just the harbinger of a flood of results to follow.
In November 2005 Silviu Radu proved a lower bound of 40 in the quarter-
turn metric; he did this by combining my edges-only result above with a clever
subgroup solver that found optimal solutions to the edges-fixed subgroup very
rapidly. He found that after solving the edges alone in at most 18 quarter-turn
moves, the remaining corners could always be solved in at most 22 quarter turns.
This lowered the upper bound to 40 moves total, the first reduction since January
1995.
Less than two weeks later Bruce Norskog improved this result from 40 quar-
ter turns to 38 by carefully considering the “hard” edge positions and finding
solutions for all the positions that have those edge positions.
But Radu was not done. In December 2005, through careful case analysis
and use of an optimal solver for some cases, he reduced Reid’s January 1995 up-
per bound in the face-turn metric from 29 to 28. The next month, January 2006,
he lowered the upper bound in the quarter-turn metric to 36 moves. This re-
sult used an earlier analysis by Bruce Norskog of a simplified cube group (taking
into account cube permutations but not orientations), and considered the specific
deep cases of that analysis.
Tomas Rokicki 93

While these results were being generated with dramatic quickness, I was
working on an algorithm for solving many related positions at once, called a coset
solver. I released my first results in January 2006, where I showed the distance
distribution for four distinct cosets, each containing 44 million positions, by find-
ing optimal solutions to all. Refinements and improvements to this idea would
eventually lead to the determination of God’s Number.
In February 1996 Herbert Kociemba found optimal solutions in the face-turn
metric to all cube positions with more than four degrees of symmetry. He rea-
soned that, if there was a distance-21 position, it was likely to have symmetry; vir-
tually all of the hard positions known at the time did. But he found no distance-21
positions. He did find 177 positions (after reduction by symmetry-equivalence)
that required 20 moves, thus vastly increasing the count of known hard distance-
20 moves. He would continue this effort with other symmetric subgroups, find-
ing more distance-20 positions over the next few months.
Over this period, from November 2005 through probably May 2006, Radu and
I were in nearly daily contact, sharing ideas and explanations. I was continuing
to run other cosets of size 44 million, but in March 2006 he demonstrated the real
power of our ideas by optimally solving 19 billion positions in the quarter-turn
metric, with essentially one program execution of about two weeks! This was
the subgroup for phase two of Kociemba’s two-phase algorithm. Unlike previous
explorations, which only used moves in the subgroup, he used all of the quarter-
turn moves. While this was not yet a coset solver (he solved the trivial coset,
which is the subgroup), it was very close. Interestingly, this gave a much more
trivial proof of his upper bound in the quarter-turn metric of 36. Later that month
he combined this with an analysis of yet another coset space to bring the upper
bound in the quarter-turn metric down to 35.
Stimulated by this accomplishment, I rewrote my coset solver to use the sub-
group used in phase two of Kociemba’s program instead of the one I had been
using. In March 2006 I started posting coset results for cosets of 19 billion posi-
tions for the half-turn metric.
The next bombshell was Radu’s proof in April 2006 that 27 moves are always
enough in the half-turn metric. He accomplished this by exploiting the fact that
the Kociemba subgroup is not fully symmetric, determining which cases were
not covered by one of three orientations of the earlier 28 proof, and solving all of
these positions.
During the first half of 2006 Radu and Kociemba had been working together
to solve all symmetric positions in the half-turn metric—if anything would find a
distance-21 position, this was probably the best hope. This was a substantial un-
dertaking; there are over 164 billion such positions, with several key subgroups
to analyze separately. In July they finally announced their results—all positions
had been solved, and distance tables for all 30 symmetry classes were published.
94 Chapter 9. Thirty Years of Computer Cubing

In addition, all 32,625 unique positions (with respect to symmetry and antisym-
metry) at distance-20 were made available. These constituted the vast major-
ity of known distance-20 positions for quite some time, accounting for a total of
1,0991,994 different overall cube positions.
Jerry Bryan contributed to the barrage of results by posting his half-turn met-
ric distance-11 result (3,063,288,809,012) in November 2006.
The period from mid-2005 to late 2006 included four lowerings of the up-
per bound in the quarter-turn metric, from 42 all the way down to 35, and two
lowerings of the half-turn metric, from 29 down to 27. More importantly, it fea-
tured tremendous advances in the technology behind computer cubing, includ-
ing very large state-space searches, large optimal subgroup solvers, and large op-
timal coset solvers. It featured unprecedented cooperation among a group of peo-
ple, communicating in the forum and by email and instant messaging, sharing
ideas and spurring each other on.
But the coming years would bring many more advances, with the application
of more computing power, additional techniques, and investigation of more sub-
groups. In May 2007 Daniel Kunkle and Gene Cooperman used a tremendous
amount of disk space and a cluster of computers to lower the upper bound in
the half-turn metric to 26 (Kunkle and Cooperman, 2007). They used a different
target subgroup (the squares subgroup), which required many terabytes of disk
space to analyze the coset space of this subgroup, which has size 65 trillion cosets.
Radu continued the cascade of new results in July 2007 by improving his lower
bound for the quarter-turn metric to 34.
Most of the upper-bounds work on God’s Algorithm to date were done by
evaluating a subgroup and its coset space, and summing the diameter of the first
and the eccentricity (maximum distance from the trivial coset) of the other, and
then trying to reduce this by considering deep cases in the subgroup and the
coset space separately. In 2008, I started using a different approach—just solve a
bunch of cosets, distributed through the coset space, like raisins in a cake; with
enough cosets solved, the distance bounds would fall fairly regularly. The nice
thing about this approach was that each coset was a separate problem, so I could
run a bunch of them on several different machines, accumulating results and
later combining them. Another improvement was, rather than finding optimal
solutions to all members of the coset, I found only near-optimal solutions. At that
point the coset solver ran fast enough that I could solve thousands on my home
machines.
In March of 2008, these ideas led to me lowering the half-turn upper bound to
25 moves, after solving 4,000 cosets just using a few desktop machines (Rokicki,
2008). This new result attracted attention from Slashdot. John Welborn of Sony
Pictures Imageworks contacted me, offering idle computer time from their ren-
dering farm. With his assistance, and some further improvements to the speed of
Tomas Rokicki 95

my program, we were able to solve more cosets and prove a bound of 23 in April
and finally 22 in August (Rokicki, 2010a). I am very grateful to Sony Pictures
Imageworks and John Welborn for their assistance.
The proof of 22 required solving 1.28 million cosets overall. Many CPUs were
involved, and being able to easily divide the problem up into batches for each
processor was one key reason we were able to perform such a large calculation.
The CPU time required was about 50 core-years (probably about 13 CPU years
assuming quad-core processors; just a few CPU minutes per coset). My estimates
of the CPU requirements for 21 and eventually 20 were much too high to consider
asking anyone for that much CPU time. For the moment, God’s Number was still
out of reach.
I was frequently asked about bounds in the quarter-turn metric, so I adapted
my code for that metric. During 2009 I was able to lower the bounds in the
quarter-turn metric to 32 (in January, requiring 400 cosets), to 31 (later January,
requiring 1200 cosets), to 30 (in February, requiring 10,000 cosets), and eventu-
ally to 29 (in June, requiring 25,000 cosets), all on my home desktop machines.
Coset solvers were not just good at lowering the upper bound on God’s Num-
ber, however. With a slight change, I was able to modify it to calculate new
distance counts as well. In June of 2009, I posted the distance count at dis-
tance 12 in the half-turn metric (40,374,425,656,248), and a day later, I posted
the distance count at distance 14 in the quarter-turn metric (50,729,620,202,582).
I had to make some changes to my program to handle the larger state spaces
at further distances, but in July I posted distance 13 in the half-turn metric
(531,653,418,284,628) and in September, distance 15 in the quarter-turn metric
(472,495,678,811,004).
The real holy grail—God’s Number in the half-turn metric—still seemed un-
reachable. My estimate at the time was that it would require about 300 CPU years
to prove 20, which was simply too much. But collaboration would prove to be
magical.
Between April 2009 and April 2010, Herbert Kociemba and I separately im-
plemented two completely independent coset solvers, trying different ideas, com-
paring performance, and confirming each other’s results. Every so often, we were
able to find another trick, another way to speed up a particular portion of the pro-
gram, or come up with another idea to eliminate some work. Together over that
period of time we were able to make the implementation about six or seven times
faster; ultimately, we were able to solve each coset in about 20 seconds on a stan-
dard desktop CPU. Without this intense cooperation, we probably would not have
been able to make the program sufficiently fast to run the whole computation.
At this time, I was starting to correspond with Morley Davidson, who was
also doing some work with the cube. He had access to an academic supercom-
puting cluster, and we started to make changes to the program for that platform.
96 Chapter 9. Thirty Years of Computer Cubing

But the amount of computer time required was still very large, so we worked
together to reduce the CPU consumption in a different way.
The coset decomposition of the space using the Kociemba subgroup has only
16 degrees of symmetry, not the full 48 degrees of symmetry of the cube. This
meant that solving all 139 million symmetry-unique cosets would actually end
up solving each position three times (six, if you include antisymmetry). What
we wanted was a way to solve many fewer of the cosets, but still guarantee that
each position was solved at least once. Standard algorithms and programs exist
for this problem, commonly known as a set-cover problem. This instance was
spectacularly huge, much too huge for any program, with 139 million rows and
226 billion columns. I had already found a simplification of the problem that
reduced the count of needed cosets from 139 million to 87.3 million, but I wanted
to see if we could do better. With Morley, I factored the problem into smaller
problems and started experimenting with different commercial and academic set
cover code; none did a good job. In April we wrote and ran our own ad hoc solver
that used a heuristic called “greedy with regret” that found a solution requiring
only 55.9 million cosets, a dramatic reduction in coset count. We had our final
breakthrough.
It had been nearly two years since we had shown that 22 moves suffice,
and we had been sharing our ideas freely. In June of 2010 Thomas Scheune-
mann, using the coset solving idea, posted distance 14 in the half-turn metric
(6,989,320,578,825,358). I also found out that another well-known researcher
was attempting to solve the problem using symbolic state-space exploration tech-
niques, which had shown to be extremely powerful on many problems. After all
the effort, would someone else beat us to twenty?
At this point we were as ready as we were ever going to be. All we needed
was CPU power. On June 21, 2010, I discussed this with a friend of mine, John
Dethridge, who happened to work at Google. He mentioned that Google was
making idle CPU time available for some projects, and he would discuss it with
his superiors. I wrote an informal proposal and shared the code, and he started
making the changes necessary for it to run on their cluster. On July 9th, we got
the go-ahead, and started the runs.
Thomas Scheunemann posted new results in the quarter-turn metric.
He posted distance-16 (4,393,570,406,220,123) on July 9th and distance-17
(40,648,181,519,827,392) on July 14th. Things were heating up.
By July 30th we had finished all the runs, we reviewed the data, reran a ran-
dom sample of the cosets on my desktops for verification, and prepared the an-
nouncement.
To help validate our results, we modified the code slightly to calculate a full
count of all positions at distances through 15. Every coset was involved in this
calculation, as was our set cover solution, so a mistake in any coset solution would
Tomas Rokicki 97

cause this number to be incorrect. We were aware that Thomas Scheunemann


was also calculating the distance-15 value, which would help confirm our result.
We validated our results against the known values for distances through 14, and
in July of 2010, we announced the distance-15 result for the half-turn metric on
the domain of the cube forum (91,365,146,187,124,313).
We held back the announcement of God’s Number until the US Rubik’s Cube
National Championship. On August 8, 2010, Morley Davidson took the stage
and announced our result to the world: God’s Number in the half-turn metric is
twenty. We had finally achieved our goal! We are grateful to Google for the CPU
time they contributed.
A week later, Scheunemann announced his computation of the distance-15
count had completed, and matched ours—all seventeen digits.

9.5 Looking Forward


Much remains to be discovered in the mathematics of Rubik’s Cube. God’s Num-
ber in the quarter-turn metric has been shown to be 26 (Rokicki, 2010b), but re-
sults for other metrics are unknown. The full set of hard positions—those requir-
ing 20 moves in the half-turn metric, or 24 or more in the quarter-turn metric—is
still unknown, as are the counts of positions at distance-16 or more in the half-
turn metric and 19 or more in the quarter-turn metric. Is there a simpler proof of
God’s Number—one that relies less on computer search, or requires significantly
less computation, or even one that yields some insight into the structure of the
group?
Then there are other twisty puzzles, such as the 4 × 4 × 4 (also known as
Rubik’s Revenge). For the revenge, right now we are about where we were in 1980
with the 3 × 3 × 3 cube—we cannot solve arbitrary positions optimally, and we
have almost no information on bounds or position counts. Indeed, right now we
estimate it will take more CPU time to optimally solve a single arbitrary position
than we spent on proving twenty moves suffice for the 3 × 3 × 3 cube. Some
progress is being made, and we hope it will not be another 30 years before we
know God’s Number for Rubik’s Revenge.

Further Reading
H. Kloosterman (1990). Close to God’s Algorithm. Cubism for Fun, 25: 19–22,
12.
R. E. Korf (1997). Finding optimal solutions to Rubik’s Cube using pattern
databases. In Proceedings of the Fourteenth National Conference on Artificial
Intelligence and Ninth Conference on Innovative Applications of Artificial Intel-
ligence, AAAI ‘97/IAAI ‘97, pp. 700–705. AAAI Press. http://dl.acm.org/
citation.cfm?id=1867406.1867515.
98 Chapter 9. Thirty Years of Computer Cubing

D. Kunkle and G. Cooperman (2007). Twenty-six moves suffice for Rubik’s Cube.
In Proceedings of the 2007 International Symposium on Symbolic and Algebraic
Computation—ISSAC 07. Association for Computing Machinery (ACM) DOI
10.1145/1277548.1277581.
T. Rokicki (2008, March 24). Twenty-five moves suffice for Rubik’s Cube. arXiv:
0803.3435v1 [cs.SC]
T. Rokicki (2010a). Twenty-two moves suffice for Rubik’s Cube. The Mathemat-
ical Intelligencer, 32(1): 33–40.
T. Rokicki (2010b). http://cube20.org/.
T. Rokicki, H. Kociemba, M. Davidson, and J. Dethridge (2013). The diameter of
the Rubik’s Cube group is twenty. SIAM J. Discrete Math., 27(2): 1082–1105.
DOI 10.1137/120867366.
D. Singmaster (1980). Notes on Rubik’s Magic cube. Mathematical Sciences and
Computing, Polytechnic of the South Bank, London, 5th edition.
M. Thistlethwaite (1981). 52-move algorithm for Rubik’s Cube. Personal letter to
David Singmaster. http://www.jaapsch.net/puzzles/thistle.htm.
10
Nim-like Games:
An Ancestry
Lisa Rougetet

The aim of this paper is to recount the ancestors—actual and potential—of the
game of Nim, taking as a starting point the game introduced by Charles Leonard
Bouton in his 1901 article (Bouton, 1901). In his paper, Bouton describes the
game as follows:
Upon a table are placed three piles of counters; the number in
each pile is arbitrary. Alternately, the two players select one of
the piles and take from it as many counters as they choose: one,
two, . . . , or the entire pile. Counters shall be taken from a single
pile and at least one shall be taken. The player who takes the
last counter from the table wins.
We will see that Nim-like games already existed in various earlier forms, times,
and places: as a recreational mathematical problem that spread in Europe during
the Renaissance and the 18th and 19th centuries, and as a board game, impos-
sible to date exactly, played in Western Africa between leaders or male adults of
a community. But first of all, let us try to answer the question, Where does the
word “Nim” come from?

99
100 Chapter 10. Nim-like Games

10.1 The Origin of the Name “Nim”: a Nimstory!


The use of the word “Nim” for Bouton’s game seems to have begun with his 1901
article. Since its publication, much has been written about the name “Nim” and
its possible origins. Bouton wrote that Nim “has been called Fan-Tan”, a game of
Chinese origin (Gardner (1988), Archibald (1918), Berge (1957)) that was played
by American students as early as the end of the 19th century (Glimm et al., 1990),
but chance is part of Fan-Tan, unlike Nim. Richard Epstein plausibly explains the
apparent motivation to find an Eastern link by the simplicity of Nim’s structure
and its strategically mathematical subtle moves (Epstein, 2009).
In May 1953, Alan Ross denied the Chinese origin of Nim in a short note pub-
lished in the Mathematical Gazette, in which he explained that Chinese names
never end with the letter m (Ross, 1953). Nevertheless, this note did not prevent
subsequent confusion between Fan-Tan and Nim. According to Ross, the most
likely explanation for the origin of the word Nim comes from the imperative of
the German verb nehmen, which means “to take” (the imperative being nimm),
and that Bouton might have chosen this word recalling his academic years spent
in Leipzig, where he received his PhD. Martin Gardner also considered this pos-
sibility in a work in 1983 in which he devoted a chapter to Nim and Hacken-
bush (Gardner, 1983).
Ross’s short note of May 1953 was not to go unnoticed, and in December of
the same year, Joseph Leonard Walsh, who earlier had been a student and then
a colleague of Bouton at Harvard University, sent a message to the editor of the
Mathematical Gazette in order to confirm the German origin of the word Nim,
explaining that Bouton had told Walsh that he had chosen nimm “as a word that
might well be used frequently during the play of the game, but he had dropped
the final “m” (Walsh, 1953). Eight years later, still in the Gazette, in October 1961
N. L. Haddock published a note about Alan Ross’s note and suggested a link be-
tween the game of Nim and Mancala, taking as a basis Harold James Ruthven
Murray’s work, A History of Board-games Other Than Chess (1952). Haddock
stated that according to Murray, the Mancala game would be of Egyptian or Arab
origin, and Nim could be a derived form for the European and American conti-
nents (Haddock, 1961).
In short, there were many varying speculations about the origins of the Nim
game and its name. Gardner (Gardner, 1983) wrote:
Did he [Bouton] have in mind the German nimm (the impera-
tive of nehmen, “to take”) or the archaic English “nim” (“take”),
which became a slang word for “steal”? A letter to The New Sci-
entist pointed out that John Gay’s Beggar’s Opera of 1727 speaks
Lisa Rougetet 101

of a snuffbox “nimm’d by Filch”, and that Shakespeare proba-


bly had “nim” in mind when he named one of Falstaff’s thiev-
ing attendants Corporal Nym. Others have noticed that NIM
becomes WIN when it is inverted.
The true story still remains nebulous and will remain so unless new infor-
mation about what Bouton had in mind when he wrote his article emerges, but
mystery is part of the history of games—especially because of the difficulty in
tracing back their origins and evolution.
Let us now present a French game, “les luettes”, which could be seen as a
distant ancestor of Nim as it could be played with objects on a table.

10.2 The game la luette, les luettes, or l’aluette


The game l’aluette is a French card game mainly played in rural and coastal ar-
eas between Gironde and the Loire estuary. It is a trick-taking game played
by four players—two teams of two—with 48 Spanish-style playing cards. This
game was still played in cafés until about 1960 but is rarely seen today. It seems
it was introduced in France during the 16th century. The game les luettes ap-
pears in François Rabelais’s Pantagruel (1532) and Gargantua (1534). Yet the
rules of the game are rarely precisely defined and, consequently, nothing en-
ables us to state that the game les luettes in Rabelais’s works corresponds with
the game l’aluette as it is known today. But in one of the first French-English
dictionaries, published in 1611 by Randle Cotgrave, we can find the following
definition at the headword “luettes”: “Luettes. Little bundles of peeces of Ivoirie
cast loose upon a table; the play is to take up one without shaking the rest, or
else the taker looseth” (Cotgrave, 1950). Cotgrave was an English lexicographer
who undertook to explain all the specificities of Rabelais’s language, and his sig-
nificant 1611 work remains today one of the main sources for the interpretation
of Rabelais’s works. All this suggests that les luettes in Rabelais consisted of chip
stacks, and that the initial idea was to take away some chips without moving the
others. These rules are closer of those of a game like Mikado, but Bouton may
have drawn his inspiration from this ancient game and abandoned the physical
skill side in favour of a more strategic angle. This kind of transformation can
also be observed in the game of Kayles by the famous puzzlist Henry Dudeney
(or the Rip Van Winkle Puzzle by Samuel Loyd): originally, it was a simple bowl-
ing game of skill; later, it turned into a more mathematical parlor version. Once
again, no connection between les luettes and Nim can be clearly established.
We will now present an arithmetical problem that can be found in the first
recreational mathematics books and which is considered more properly as an
ancestor of Nim.
102 Chapter 10. Nim-like Games

10.3 Luca Pacioli, Italy, 1508


Mathematical recreations can be considered a genre that includes mathematical
writings on games and how to play them, similar educational material partic-
ularly designed to be entertaining, and the launch of mathematical challenges
between scientists in their correspondence. This new genre most significantly
developed thanks to Bachet’s and Ozanam’s works of the 17th century, but it was
Luca Pacioli who introduced it earlier, at the end of the 15th century.
Our interest here mainly deals with the first books of mathematical recre-
ations that were aimed to “pique one’s curiosity”. We will focus in particular on
recreational puzzles presented as games opposing two players who take turn try-
ing to reach a given number, 𝑛, by adding up numbers in the range from 1 to 𝑘.
Such recreational problems predate Bouton’s Nim. The player who knew the so-
lution could easily impress his opponent by displaying his mastery during each
game; it was a way to be a social success, even to have a hold over the people who
did not have the key. This tendency can be observed too, as we will see further
on, in the practice of Tiouk-Tiouk in Western Africa.
The earliest simplified variation of Nim was found in Europe in a treatise
written by the Italian mathematician Fra Luca Bartolomeo de Pacioli (1445–1517).
Pacioli was one of the most famous mathematicians of his time. According to
David Singmaster, Pacioli’s De Viribus Quantitatis can be considered one of the
first works entirely devoted to mathematical recreations (Singmaster, 2008). It
is organised into three parts. The first includes arithmetical recreations, the sec-
ond part consists of problems involving geometry and topology, and the third part
contains a few hundred proverbs, poems, riddles, and puzzles.
One of Pacioli’s key aims was to reveal the power of numbers and to demon-
strate that they could be understood in a concrete way thanks to the various card
games, dice, Tarot, and board games he proposed. One problem from the first
part (see Figure 10.1) is the following: “finish any number before the opponent,
without taking more than a certain finite number” (Pacioli, 1508).
This rather unclear wording makes sense when Pacioli gives the solution: he
suggests that two players reach the number 30 by adding, in turns, numbers rang-
ing from 1 to 6. In fact, it is a simplified version of Bouton’s Nim game—one that
is played with only one pile consisting of 30 objects, and in which each removal
is limited to a maximum of six objects. This version is called “additive” because
one adds numbers instead of reducing piles, which was often the case in the first
versions of Nim. Before revealing the method to win every time, Pacioli explains
that his game is recreational, undeceptive, and legitimately mathematical, and
that it is fully entitled to be part of a mathematics lesson. Next, Pacioli considers
if there is any advantage for the first or the second player to begin the game, and
then immediately gives the winning strategy to be applied: four “safety” steps,
2, 9, 16, and 23 have to be reached (but Pacioli does not really explain why it’s
Lisa Rougetet 103

Figure 10.1. Item XXXIIII, proposed by Pacioli in


the first arithmetical part of De Viribus Quantitatis.
© Alma Mater Studorium Università di Bologna—
Biblioteca Universitaria di Bolonga. Further repro-
duction or duplication by any means is prohibited.

desirable to reach these numbers). Then he suggests a general method to find


the safety steps of any game: “always divide the number that you wish to arrive
at by one more than has been taken and the remainder of the said division will
always be the first [step of the] progression [. . . ]” (Pacioli, 1508).
However, Pacioli never gives an explanation by generalizing numbers; each
case is studied independently and no formula, for which specific data to each
example had only to be replaced, is developed. This is due to the belated devel-
opment of algebra and the lack of an appropriate symbolism during the Renais-
sance.
The Quantitatis manuscript is a collection of mathematical ludi, i.e., recre-
ational mathematics, including games or problems through which the author
wished to teach mathematics. Their aim was to avoid the tiresome repetition
of mathematical exercises. Pacioli’s manuscript can be considered as the first
true treatise on the subject. Vanni Bossi points out a magical nature, easily in-
telligible, in most of Pacioli’s assertions: it would seem that Pacioli did want the
secret of his methods to remain unrevealed, in order to surprise the audience;
indeed, “secret” is the fundamental principle of any magic trick. Keeping this
secret is the essential condition for being able to amaze one’s friends, especially
women, maxime donne, and those who do not know mathematical principles be-
cause they had no access to arithmetic knowledge (Bossi, 2008). This dimension
of intellectual domination thanks to the control of the game is also to be found
in the West African game Tiouk-Tiouk that is treated below.
Pacioli did not claim to be the originator of all his material—in fact, many
of the problems he suggested came from more ancient works that were stud-
ied or talked about in public schools at that time and communicated verbally in
lessons (Heeffer, 2004). His manuscript was kept in the archives of the University
of Bologna for nearly five hundred years without its being published, and it had
104 Chapter 10. Nim-like Games

Figure 10.2. Claude-Gaspard Bachet de Méziriac


(1581–1636). Source: Wikimedia Commons.

rarely been consulted since the Middle Ages, but it was undoubtedly a direct or in-
direct source for many later works. Actually, the additive version of Nim crossed
centuries and frontiers, and it was to appear again in various books of recreational
mathematics as early as the 17th century. As we will see, the mathematical prob-
lem of the recreation often remains exactly the same (how to reach 𝑛 by summing
up numbers between 1 and 𝑘), and usually it is only the presentation that varies,
and not always that. For example, in Problemes plaisans et delectables, qui se font
par les nombres (1612), the famous book by Claude-Gaspard Bachet (see Figure
10.2) about mathematical recreations, we find a version of Nim similar to the one
formulated by Pacioli.
Problem XIX (Figure 10.3) studies the case when two players must reach
100 by adding numbers ranging from 1 to 10, “or any smaller number [. . . ] such
as the player who will say the number that achieves 100 is recognized the win-
ner” (Bachet, 1612). Then Bachet explains the strategy that ensures the win: “But
to win unerringly, add 1 to the number that cannot be exceeded, here 10; you ob-
tain 11 and then, always remove 11 of the number to be reached, 100; you will
obtain these numbers 89, 78, 67, 56, 45, 34, 23, 12, 1”. Bachet rightly points out: “if
the two players know the trick, the one who begins will inevitably win.” Thus, he
advises to choose an opponent who does not know anything about the strategy,
and nevertheless to remain clever:
Lisa Rougetet 105

So, if your opponent ignores the subtlety of the game, you must
not take the same remarkable numbers necessary to win unfail-
ingly, because doing so, you will highlight the trick, and if he
is a man of good intelligence, he will immediately notice these
numbers, as he will see you are always choosing the same: but
at the beginning, you can say other numbers on the fly, until
you came nearer the wanted number, because then you will be
able to add some of the necessary numbers for fear of being sur-
prised.

Figure 10.3. Problem XIX as presented in Bachet’s


1612 work.

Bachet’s book became an important reference for later authors of mathemat-


ical recreations books. The frequent travels of scientists across Europe to visit
libraries, and their epistolary correspondence, helped the knowledge to circulate
and to be spread. Thus, it is not surprising to find a recreation presented exactly
in the same manner shortly after Bachet’s publication: this holds for the German
Daniel Schwenter (1636), the Frenchman Jacques Ozanam (1694), and later for
the English private teacher of mathematics, John Jacksons (1821). However, in
1749, the Frenchman André Joseph Panckoucke (1703–1753) presented a prob-
lem called “Le Piquet des Cavaliers” (Panckoucke, 1749) (see Figure 10.4), and
the wording he used is more fictionalized than in the books of Pacioli, Bachet,
Ozanam, and Schwenter: “Two friends are riding; one of them suggests to play
‘one cent (one hundred) de Piquet’ without cards. Both agree that: (1) The first
106 Chapter 10. Nim-like Games

Figure 10.4. “Le Piquet des Cavaliers”, a pastime


proposed in Panckoucke (Panckoucke (1749), p130).

who will reach 100 will not pay for his dinner, and (2) They will not be allowed
to take in turns a number higher than 10.”
Originally, Piquet was a card game. Up to the middle of the nineteenth cen-
tury, it was one of the three games considered as the most dignified, along with
chess and backgammon. During the seventeenth century, it was played with 36
cards (the lowest being the 6). In play, the two players must take, in turns, a
card from the pack and add its value to the sum already obtained with the former
draws. The riders of our problem do not have any cards—which would not be
very useful while riding—and they play verbally, instead. The game is equiva-
lent to one pile Nim.
As Bachet advises in his solution, Panckoucke encourages the reader not to
insist in reaching every safety step, called époques (epochs), but only those that
are close to the number to be reached—a rather simple strategy, which is nev-
ertheless efficient enough to dine cheaply! Some 40 years later, the Frenchman
Henry Decremps (1746–1826) used this phrase: “Principes mathèmatiques sur
le piquet à cheval, ou l’art de gagner son dîner en se promenant” in his Codicile
de Jérôme Sharp (Singmaster, 2004). This assertion reinforces the idea that the
player who knows the winning strategy can take advantage of his knowledge to
obtain a favour from his fellow player. This horse-riding version was to be found
20 years later, in the physician and inventor Edmé-Gilles Guyot’s work about
mathematical and physical recreations: “two riders who travel together are bored
when thinking of the distance that is still to be covered; they create a game that
could help them to pass the time more pleasantly and agree to play a ‘Cent de
Piquet’ [. . . ]” (Guyot, 1955). What is at stake here is no longer the winning of a
dinner; it is simply a verbal recreation that helps pass the time. We can point out
Lisa Rougetet 107

the use of the word “recreation” instead of “problem”, which was used until then
when referring to the object of the statement.
The additive version of Nim crossed the Channel and landed in William
Hooper’s book entitled Rational Recreations (1783). The presentation of the
eighth recreation of the first volume, in which we can find the additive version of
Nim, is slightly different from the “problems” or “recreations” that were present
in the former works. First, the recreation is entitled The Magical Century. Then
Hooper decides to sum up alternately counters piled up on a table, until one gets
100, without adding more than ten counters at the same time. Hooper uses a
more visual configuration of the recreation, as he manipulates counters instead
of abstract values that must be kept in mind. This recreation becomes similar
in its representation to the Nim game of Bouton who considered variously sized
piles of counters.
At this point, we stop our study on the ancestors of Nim related to the one-
pile additive version. The recreation was not to vary much after Hooper’s and
Jackson’s publications, and it can be found in numerous works of mathematical
riddles and recreations throughout the nineteenth century, presented as “Piquet
sans cartes” or simply as a two-player game (Singmaster, 2004). Sometimes the
game is set out under a subtractive version, and a version “misère” appeared, in
which the last player loses. The range of works we have analysed represents the
very first sources in which the ancestral version of Nim can be found, and we can
understand that it is rather simple to win when playing these additive versions.
Things become more laborious when it comes to Bouton’s Nim of 1901: it is still
possible to do some mental arithmetic, but a more intricate mathematical knowl-
edge, abstract thinking, and a longer time of reflection are required to reach the
win. This is also the case for combinatorial games that came after Nim, such as
Wythoff’s Nim or Moore’s Nim-k, the solutions of which appeal to even deeper
mathematical knowledge. The initial aim of the first Nim games that were dis-
played as mathematical recreations has disappeared over time; it is no longer a
matter of creating puzzles in order to impress the fairer sex during high-society
evenings, but a matter of discovering interesting mathematical properties, even
discovering new ones (John Conway’s surreal numbers theory, for example) that
could lead to theories still undeveloped.
The next part of our study will be devoted to Tiouk-Tiouk, an African game.
It could seem far from Bouton’s Nim as it requires a board and offers the possibil-
ity to block a piece, but yet is similar to Bouton’s Nim in its solution. Nowadays,
such games are called NimIn for NimIncognito (Epstein, 2009). Additionally,
Tiouk-Tiouk might be an ancestor of the Nim game, but once again tracing its
sources and its first appearances has proved to be difficult, especially because its
“boards” were frequently made of sand!
108 Chapter 10. Nim-like Games

10.4 Tiouk-Tiouk in Western Africa


In 1955 Charles Béart, a school principal in tropical Africa, published a work
in two volumes in which he made an inventory of games and toys in Western
Africa (Béart, 1955). One chapter is devoted to two-player combinatorial games
without chance, such as board games (Chess, Draughts, Tic-Tac-Toe), twelve-box
games (Awélé and others), and finally Tiouk-Tiouk.
Tiouk-Tiouk is played on a grid of 6, 8, 10, or 12 rows. The number of rows
must be even. The first row is filled with seeds and is allocated to one player, and
the last row is filled with sticks and is attributed to the other player (Figure 10.5).

Figure 10.5. The Tiouk-Tiouk initial position.


(West African Games and Toys, Ch. Béart, IFAN
Memorial Series, 42, IFAN, Dakar, 1955. Used with
permission.)

The two players alternate turns, and “each counter can be moved forwards
or backwards as often as wanted, and as many squares as wanted, too, but can-
not jump over an opponent piece. The player who succeeds in blocking all the
counters of his partner will win” (Béart, 1955). If we compare this version with
Bouton’s Nim, we have in this case 6, 8, 10, or 12 piles, and each contains the
same number of objects; the gap between the seeds and the sticks is the same for
each row. Transcribed into binary system (if we follow Bouton’s instructions to
solve Nim), the starting position is a safe combination and the winner is the one
who plays in second turn.
Lisa Rougetet 109

Béart specifies that Tiouk-Tiouk is generally proposed to a shepherd by a


griot1 who “generously offers him to draw the board and take the first-move ad-
vantage.” But we know now how disadvantageous it is to start the game! Yet,
the griot does not cheat because “it is unnecessary, he is sure to win, when he
wants, if he does not start, and quite sure to win if he starts.” However there is a
lot at stake with the outcome of this game. Tiouk-Tiouk was listed in 1955 but it
is impossible to date this game precisely and even to find its geographical origin.
Béart classifies it within the grid games that have a peculiar status: “these are
serious games par excellence, adult games; they are or were mainly the privilege
of adults, of men, even of leaders; women and children could only imitate these
games.” This elitist aspect of Tiouk-Tiouk and other grid pattern games could be
compared to the sixteenth–seventeenth century mathematical recreations that
were listed in works intended for educated classes who could afford to buy these
books. “The most simple explanation for this singular situation lies in the fact
that these games were introduced by a dominant society setting among a subju-
gated population.” Indeed, we can understand the intellectual pressure one can
exert on somebody else who would not know the strategy and who would lose
each game.
Games and mathematical riddles have been puzzling people for centuries,
“the human nature has changed but little, and problems that whet the imagina-
tion prove more fascinating than do the prosaic ones, whether a person lives in
the sixteenth century or in the twentieth” (Sanford, 1927). Mathematical recre-
ations were far from being out-fashioned at the beginning of the twentieth cen-
tury. Samuel Loyd’s and Henry Dudeney’s puzzles and riddles are among the
most popular contributions, as well as Martin Gardner’s monthly columns for
Scientific American magazine; human infatuation for mysterious problems is time-
less. This interest for mathematical recreations has enabled complexity to emerge
in the solutions of the problems and thus some mathematical theories to de-
velop (Rougetet, n.d.). Recreations have been considered as challenges to be
taken up, yet within an entertaining frame. This tendency can be found as early
as the first versions of Nim, of which solutions are rather easy to find out, pro-
vided that we take some time to do so. On the other hand, some nontrivial solu-
tions were to appear later with Bouton’s Nim and its variations.
From that time, the real mathematical history of Nim and its theorization
began, when a sufficient keenness, even a genuine mathematical skill, were nec-
essary to discover winning strategies. But this is another story. . . .
1 A “griot” is a member of a class of traveling poets, musicians, and story tellers who maintain a

tradition of oral history in parts of West Africa.


110 Chapter 10. Nim-like Games

Further Reading
R. Archibald (1918). The binary scale of notation, a Russian peasant method of
multiplication, the game of Nim and Cardan’s Rings. The American Mathe-
matical Monthly, 25(3): 132–142.
C. G. Bachet (1612). Problémes plaisans et delectables qui se font par les nombres.
Pierre Rigaud & Associez, Lyon, 1st edition.
C. Béart (1955). Jeux et jouets de l’ouest africain. 42. IFAN Dakar, Tome I et II.
C. Berge (1957). Théorie générale des jeux à 𝑛 personnes. Gauthier-Villars, Paris.
V. Bossi (2008). A lifetime of puzzles: A collection of puzzles in honor of Martin
Gardner’s 90th birthday, chapter Magic and Card Tricks in Luca Pacioli’s De
Viribus Quantitatis. In Gardner et al. (2008).
C. L. Bouton (1901). Nim, a game with a complete mathematical theory. Annals
of Mathematics, 3(1/4): 35–39. http://www.jstor.org/stable/1967631.
R. Cotgrave (1950). A dictionarie of the French and English tongues. University of
South Carolina Press, Columbia.
R. A. Epstein (2009). The theory of gambling and statistical logic. http://site.
ebrary.com/id/10343098.
M. Gardner (1983). Wheels, life, and other mathematical amusements. W. H.
Freeman, New York.
M. Gardner (1988). Hexaflexagons and other mathematical diversions: the first Sci-
entific American book of puzzles & games. University of Chicago Press, Chicago.
M. Gardner, E. D. Demaine, M. L. Demaine, and T. Rodgers (2008). A lifetime
of puzzles: A collection of puzzles in honor of Martin Gardner’s 90th birthday.
A. K. Peters, Ltd., Wellesley, Massachusetts.
J. Glimm, J. Impagliazzo, I. M. Singer (1990). The Legacy of John von Neumann.
American Mathematical Society, Providence, R.I.
E.-G. Guyot (1955). Nouvelles récréations physiques et mathématiques, Contenant,
Toutes celles qui ont été découvertes et imaginées dans ces derniers temps, sur
l’Aimant, les Nombres, l’Optique, la Chymie, etc. et quantité d’autres qui n’ont
jamais été rendues publiques. Où l’on a joint leurs causes, leurs effets, la manière
de les construire, et l’amusement qu’on peut en tirer pour étonner agréablement,
IFAN Dakar, Tome I et II.
N. L. Haddock (1961). Mathematical note no. 2973: A note on the game of Nim.
The Mathematical Gazette, 45(353): 245–246.
Lisa Rougetet 111

A. Heeffer (2004). Récréations mathématiques (1624): A study on its authorship,


sources and influence. Centre for Logic and Philosophy of Science, Ghent, Bel-
gium. http://logica.ugent.be/albrecht/thesis/Etten-intro.pdf.
L. Pacioli (1508). De viribus quantitatis. Milano.
A.-J. Panckoucke (1749). Les amusements mathématiques, precedés Des Eléments
d’Arithmétique, d’Algèbre & de Géométrie nécessaires pour l’intelligence des Prob-
lêmes. Lille.
A. Ross (1953). Mathematical note no. 2334: The name of the game of Nim. The
Mathematical Gazette, 37(322): 119–120.
L. Rougetet (submitted). A prehistory of Nim. The College Mathematics Journal.
V. Sanford (1927). The history and significance of certain standard problems in
algebra,. PhD thesis, Teachers college, Columbia University, New York City.
D. Singmaster (2004). Sources in recreational mathematics: an annotated bibli-
ography. School of Computing, Information Systems and Mathematics, South
Bank University, London, 9th preliminary edition.
D. Singmaster (2008). A lifetime of puzzles: A collection of puzzles in honor of
Martin Gardner’s 90th birthday, see the chapter, De Viribus Quantitatis by Luca
Pacioli: The First Recreational Mathematics Book. In Gardner et al. (2008).
J. Walsh (1953). Correspondence: The name of the game of Nim. The Mathemat-
ical Gazette, 37(322): 290.
Part 4

Puzzles
A mathematician sees puzzles everywhere, as the five papers of this section
show. The first paper is about arranging pool balls in a specific way; the second,
about arranging students into classes and then into fewer classes; the third is
about running Conway’s Game of Life backwards; the fourth is about weighing
coins; and the fifth involves physical manipulation of rubber bands.
11
Triangles of Absolute
Differences
Brian Chen
YunHao Fu
Andy Liu
George Sicherman
Herbert Taylor
Po-Sheng Wu

11.1 Introduction
In 1976 George Sicherman thought of the following problem while watching a
pool game in Buffalo: Could the fifteen pool balls be arranged in the usual tri-
angular array so that apart from the back row of five numbers, each number in
a subsequent row is the absolute difference of the two numbers immediately be-
hind it?
As an illustration, possible arrangements with the pool balls numbered from
1 to 6 and from 1 to 10 are shown in Figure 11.1.
George found a solution to his problem, and established its uniqueness up
to reflection about the triangle’s vertical axis of symmetry. He communicated
the problem to Martin Gardner (Sicherman, 1976) who published the problem in

115
116 Chapter 11. Triangles of Absolute Differences

Figure 11.1. Solutions to the triangle of absolute


differences (TOAD) problem of orders 2 and 3.

his famed column “Mathematical Games” in the magazine Scientific American


in April 1977 (Gardner, 1989).
The main result of this paper is that no such arrangements exist which con-
tain more than fifteen pool balls.

11.2 The Anatomy of a TOAD


A triangle of absolute difference, or TOAD for short, is defined to be a trian-
gular array of integers having the following properties.
(1) There are 𝑛 integers on the top row for some positive integer 𝑛.
(2) Each row below has one fewer number than the row above it.
(3) Each number below the top row is the absolute difference of the two adjacent
numbers in the row immediately above.
(4) The integers are from 1 to 𝑛(𝑛 + 1)/2, each appearing exactly once.
Such a TOAD is said to be of order 𝑛. The reflection of a TOAD about its
vertical axis of symmetry is another TOAD. We will treat each pair of mirror twins
as a single TOAD. Without loss of generality, we may use either form of the TOAD
at our convenience.
Each TOAD has a spine defined by the following construction. We call the
bottom number of a TOAD its foot. From the foot, we draw two line segments
connecting it to the two numbers of which it is the absolute difference, a thin
Brian Chen et al. 117

Figure 11.2. The unique triangle of absolute differ-


ence (TOAD) of order 5, shown with its foot (5) at
bottom, its spine as doubled-line segment path, and
its head (15) at top.

line segment to the smaller one, and a thick line segment to the larger one. The
smaller number is called a hand, and no further line segments are drawn from
it. From the larger number, we draw two more line segments as before. This is
continued until the spine reaches the top row. The larger number on the top row
is called its head. This is illustrated in Figure 11.2 for the unique TOAD of order
5. The spine consists of the numbers 5 (foot), 9, 11, 12, and 15 (head) while the
hands consist of the numbers 4, 2, 1, and 3.
A TOAD of order 𝑛 has a spine consisting of 𝑛 numbers from foot to head and
𝑛 − 1 hands. The head is equal to the sum of the foot and all the hands. Since the
head is at most 𝑛(𝑛 + 1)/2 while the sum is at least 1 + 2 + ⋯ + 𝑛 = 𝑛(𝑛 + 1)/2, the
head must be equal to 𝑛(𝑛 + 1)/2 and the foot and all the hands must collectively
be 1, 2, . . . , 𝑛.
Note that there is exactly one hand or foot on each row, so that the hand or
foot is the smallest number of the row. The head is clearly the largest number of
the top row. It follows that the largest number on each row is on the spine.
From the head and the top hand, if we draw two slanting lines towards the
sides of the TOAD, as shown in the diagram above, we can divide the TOAD into
three parts. The two triangles on the side are called quasi-TOADs, with their own
feet, spines, heads, and hands. They are TOADs except for the fact that they do
not have property 4 of the definition of a TOAD.
In the diagram above, the quasi-TOAD on the right is of order 1. Its foot and
head coincide (number 13), and it has no hands. The quasi-TOAD on the left is
of order 2. The spine connects the foot (number 8) directly to the head (number
14), and it has a single hand (number 6).
118 Chapter 11. Triangles of Absolute Differences

For 𝑛 ≥ 3, the quasi-TOADs of a TOAD of order 𝑛 have spines of combined


length 𝑛 − 2, and a total of 𝑛 − 2 feet and hands. This is still true even if one of
the quasi-TOADs is empty, which happens if the spine runs along one side of the
TOAD.

11.3 The Nonexistence of TOADs of order 9 or higher


Suppose we have a TOAD of order 𝑛 ≥ 3. The minimum values of the 𝑛 − 2 feet
and hands of the quasi-TOADs are 𝑛 + 1, 𝑛 + 2, . . . , 2𝑛 − 2. Hence the sum of their
heads is at least
(𝑛 − 2)(3𝑛 − 1) 3𝑛2 − 7𝑛 + 2
(𝑛 + 1) + (𝑛 + 2) + ⋯ + (2𝑛 − 2) = = .
2 2
If there is only one quasi-TOAD, its head is at most 𝑛(𝑛 + 1)/2 − 1. From
3𝑛2 − 7𝑛 + 2 𝑛2 + 𝑛 − 2
≤ ,
2 2
we have 𝑛2 ≤ 4𝑛 − 2. This holds if and only if 𝑛 ≤ 3.
If there are two quasi-TOADs, the sum of their heads is at most
𝑛(𝑛 + 1) 𝑛(𝑛 + 1)
−1+ − 2.
2 2
From (3𝑛2 − 7𝑛 + 2)/2 ≤ 𝑛2 + 𝑛 − 3, we have 𝑛2 ≤ 9𝑛 − 8. This holds if and only
if 𝑛 ≤ 8. It follows that TOADs of order 9 or higher do not exist.
This proof was found in 1977 by Herbert Taylor who communicated it to
Martin Gardner (Taylor, 1977). It has not been published until now.

11.4 The Nonexistence of TOADs of order 8


For 𝑛 = 8, the equality case holds in the inequality 𝑛2 ≤ 9𝑛−8 from the preceding
section. If a TOAD of order 8 exists, its head is 36 and its foot and hands are
1, 2, . . . , 8. It follows that we have two quasi-TOADs. Their heads are 35 and 34,
and their feet and hands are 9, 10, . . . , 14. Thus each quasi-TOAD must be of
order 3.
Consider the bottom three rows of the TOAD. Let the foot be 𝑥, the hand on
the second row from the bottom 𝑦, and the hand on the third row from the bottom
𝑧. Without loss of generality, we may assume that the spine starts off towards the
left. There are two cases, according to where the spine intersects the third row
from the bottom.
Brian Chen et al. 119

Case 11.4.1. The spine continues towards the left; see Figure 11.3.

Figure 11.3

Since the numbers 1 to 14 form the hands and feet of the TOAD and the two
quasi-TOADs, the number 𝑥 + 𝑦 must be at least 15. Hence, one of 𝑥 and 𝑦 is 8
and the other is 7, so that 𝑧 ≤ 6. Since 𝑧 < 𝑦, we must have A = 𝑦 + 𝑧 ≤ 14. This
is a contradiction since A is neither a foot nor a hand of either the TOAD or one
of the quasi-TOADs. Thus this case does not yield a TOAD of order 8.

Case 11.4.2. The spine turns towards the right; see Figure 11.4.

Figure 11.4

As in Case 11.4.1, one of 𝑥 and 𝑦 is 8 and the other is 7, so that 𝑧 ≤ 6. Since the
number on the spine is the largest of the row, we must have A = (𝑥 + 𝑦 + 𝑧) − 𝑦 =
𝑥 + 𝑧 ≤ 14. We have the same contradiction as before. Thus this case does not
yield a TOAD of order 8 either.

11.5 The Nonexistence of TOADs of order 7


When 𝑛 = 7, the inequality 𝑛2 ≤ 9𝑛 − 8 is no longer tight. Nevertheless, if a
TOAD of order 7 exists, we can still make deductions about its structure. Its head
is 28 and its foot and hands are 1, 2, . . . , 7. Now 8 + 9 + 10 = 27. It follows that
one of the quasi-TOADs is of order 3, with 27 as its head and 8, 9, and 10 as its
foot and hands, and the remaining two numbers are chosen from 17, 18, and 19.
120 Chapter 11. Triangles of Absolute Differences

Figure 11.5

Without loss of generality, we may assume that this quasi-TOAD is on the left
side, as shown in the Figure 11.5. We consider two cases.

Case 11.5.1. C ≥ 19.


Then C ≥ D ≥ 8. Hence E = 27 or 28. However, these numbers had been
reserved for the heads of the TOAD and the quasi-TOAD of order 3. We have a
contradiction.

Case 11.5.2. C ≤ 18.


Since B = 8, 9, or 10, A must be a hand of the TOAD. It follows that the spine
of the TOAD must start off as shown in the diagram above, where 𝑥 is the foot of
the TOAD. Since 𝑧 − 𝑦 < 7, F = 𝑦 + 𝑧. Since the head is the largest number on
the top row, G = 𝑥 + 𝑦 + 𝑤 and H = 𝑥 + 𝑤 − 𝑧. Each of 𝑦 + 𝑧, 𝑥 + 𝑤 − 𝑧 and
𝑥 + 𝑦 is at most 13. Since 8, 9, and 10 are the foot and hands of the quasi-TOAD
of order 3, these three numbers must be 11, 12, and 13 in some order. However,
this means that both the foot and the hand of the quasi-TOAD of order 2 are at
least 14, but its head is at most 26. We have a contradiction. See Figure 11.6.

Figure 11.6
Brian Chen et al. 121

11.6 The Nonexistence of TOADs of order 6


In this final section, we abandon the anatomy of a TOAD and turn to other ap-
proaches. We present two different parity arguments. Each may be generalized
to cover certain cases for 𝑛 ≥ 9, but they overlap our main result in Section 11.3.
The first proof was found in 1976 by George Sicherman (Sicherman, 1976).
We work with arithmetic modulo 2 so we may replace differences by sums. The
first six rows of the reduced Pascal’s Triangle are shown in Figure 11.7.

Figure 11.7

Suppose an order 6 TOAD exists. Let the numbers on the top row be 𝑎, 𝑏, 𝑐,
𝑑, 𝑒, and 𝑓 in that order. Then the numbers in the second row are 𝑎 + 𝑏, 𝑏 + 𝑐,
𝑐+𝑑, 𝑑 +𝑒, and 𝑒+𝑓. In modulo 2, those in the third row are 𝑎+𝑐, 𝑏+𝑑, 𝑐+𝑒, and
𝑑+𝑓, those in the fourth are 𝑎+𝑏+𝑐+𝑑, 𝑏+𝑐+𝑑+𝑒, and 𝑐+𝑑+𝑒+𝑓, those in the
fifth 𝑎 + 𝑒 and 𝑏 + 𝑓, and the only number in the sixth row is 𝑎 + 𝑏 + 𝑒 + 𝑓. Hence
their sum is 6𝑎 + 8𝑏 + 8𝑐 + 8𝑑 + 8𝑒 + 6𝑓, which is even. Since 1 + 2 + ⋯ + 21 = 231
is odd, we have a contradiction.
The second proof was found by Brian Chen in 2008, when he was in Grade 4.
Suppose an order 6 TOAD exists. We partition its 21 numbers into seven triples,
identified by different letters, as shown in Figure 11.8. Each triple contains an
even number of odd numbers. Hence the TOAD contains an even number of
odd numbers. However, there are eleven odd numbers from 1 to 21, and we have
a contradiction.

11.7 TOADs of order 5 or lower


The unique TOAD of order 1 is trivial, and there are two elementary TOADs of
order 2. An order 3 TOAD has an order 1 quasi-TOAD which must be the number
4 or 5. If it is 4, this leads to the TOADs with top rows (4, 1, 6) and (1, 6, 4). If it
is 5, this leads to the TOADs with top rows (5, 2, 6) and (2, 6, 5). Hence there are
only four TOADs of order 3.
122 Chapter 11. Triangles of Absolute Differences

Figure 11.8

We have proved in Section 11.3 that any TOAD of order 4 or more must have
two nonempty quasi-TOADs. Thus an order 4 TOAD has two quasi-TOADs of
order 1. There are four cases.

Case 11.7.1. The top hand of the TOAD is 1.


Then 9 is not in the top row, so that 8 must be one of the quasi-TOADs.
Whether it appears next to 1 or 10, 7 will not appear in the top row. Hence the
other quasi-TOAD must be 6. This leads to the TOADs with top rows (6, 1, 10, 8)
and (6, 10, 1, 8), respectively.

Case 11.7.2. The top hand is 2.


Then one of the quasi-TOADs must be 9. Whether it appears next to 2 or 10,
8 and 7 will not appear in the top row, so that the other quasi-TOAD must be 6.
It is routine to verify that we will need two copies of 4 to complete the TOAD.

Case 11.7.3. The top hand is 3.


Then the quasi-TOADs must be 8 and 9. This leads to the TOADs with top
rows (8, 3, 10, 9) and (8, 10, 3, 9), respectively.

Case 11.7.4. The top hand is 4.


Then all of 7, 8, and 9 need to be quasi-TOADs, which is clearly impossible.
Hence there are only four TOADs of order 4.

An order 5 TOAD has a quasi-TOAD of order 1 and a quasi-TOAD of


order 2. The latter comes from either 8+6=14 or 7+6=13. We may assume that
it is on the left side and let 𝐻 be its head. There are four cases, according to the
positions of H and 15. Note that 15 − H = 1 or 2.

Case 11.7.5. H and 15 are in the first and third positions from the left; see Figure
11.9.
Brian Chen et al. 123

Figure 11.9

A must be 7, 8, or 9, and it cannot be a hand. It follows that B cannot be a


hand either. However, B must be 1 or 2. This is a contradiction.

Case 11.7.6. H and 15 are in the second and fourth positions from the left; see
Figure 11.10. C is either 1 or 2 and is, therefore, a hand. In order for B = A − 𝑣
not to be a hand, we must have A = 8 and 𝑣 = 1, but then H = 14 and 14 will
appear again in the second row from the top. Hence, B and C are both hands, a
contradiction.

Figure 11.10

Case 11.7.7. H and 15 are in the first and fourth positions from the left; see Figure
11.11.
As in Case 11.7.5, B = A − 𝑣 must be a hand, so that C is on the spine. Now
C = 15 − A must be 9 as otherwise there is no possible value for the number on
the spine below it. Now all of the numbers from 10 to 15 must appear in the top
two rows, and we are one space short since A, 𝑣, H − A, and B are all less than 9.

Case 11.7.8. H and 15 are in the second and third positions from the left; see
Figure 11.12. We have B = 1 or 2, and as in Case 11.7.7, C = 10, 11, or 12.
Routine checking yields the unique solution featured in Section 11.2.
124 Chapter 11. Triangles of Absolute Differences

Figure 11.11

Figure 11.12

Further Reading
M. Gardner (1989). Penrose tiles to trapdoor ciphers. W. H. Freeman, New York.
G. Sicherman (1976). Private communication to Martin Gardner.
H. Taylor (1977). Private communication to Martin Gardner.
12
Generalization of a Puzzle
Involving Set Partitions
Michael L. Fredman
Daniel A. Kleitman
Peter Winkler

We suppose that the students are divided into 𝑐 classes and then also into 𝑐−𝑘
classes, and we seek to minimize the number of students who are each assigned to
a larger class in the second partition than in the first one. We show that this min-
imum number is the sum of the sizes of the 𝑘+1 smallest of the first set of classes.
(Explicitly, with the various original class sizes arranged in increasing order, this
is the sum of the first 𝑘+1 of them.) A more detailed question, which we also
answer, is, Given two sets of class assignments for the students, the first with 𝑐
classes and the second with 𝑐−𝑘 classes, how few students can be in larger classes
in the second arrangement as compared with the first? In this case we show that
a lower bound is given by the sum of the 𝑘+1 smallest class sizes present in the
first arrangement but absent in the other. (We mean here that, for example, if
a class size is repeated four times in the first arrangement and twice in the sec-
ond, it is absent twice in the second arrangement). We also give an algorithm for
calculating the exact minimum, which may be greater than that number.
The puzzle cited in our title proposed the special case where the students
were divided into 𝑐 classes but now into only 𝑐−1, the object being to prove that
at least two students must be in larger classes than before. This puzzle was passed

125
126 Chapter 12. Generalization of a Puzzle Involving Set Partitions

to the third author by Ori Gurel-Gurevich, a mathematician at the University of


British Columbia. Gurel-Gurevich heard it from his army friend, Alon Amit, but
the puzzle may go back much further in time.
The lemma below provides a simple lower bound to the number of elements
that must move from a block in one partition to a larger block in a second parti-
tion, that holds for any two partitions 𝒫 and 𝒬 of a set 𝑆.

Lemma 12.1. Suppose the block sizes in two partitions 𝒫 and 𝒬 of a finite set 𝑆 are
listed in increasing order of their absolute values, with positive signs on the block
sizes in 𝒫 and negative signs on those from 𝒬. Where blocks are the same size, those
of 𝒬 are listed first. Let 𝑀 denote the resulting sequence, and let 𝑡 be the largest
partial sum of 𝑀. Then 𝑡 is the smallest possible number of elements (students) that
move to larger classes, in going from classes in 𝒫 to those in 𝒬.

Proof. Let 𝑦 be the last block size counted when the maximum partial sum 𝑡 is
first reached. There are then at least 𝑡 more elements that are in block sizes of 𝑦
or less in 𝒫 than in 𝒬. It follows that at least 𝑡 of the elements in such blocks in
𝒫 must be in blocks larger than 𝑦 in 𝒬, proving the claim.
To see that there is a way to make new assignments with exactly 𝑡 students
moving to larger classes, imagine a histogram of the sequence 𝑀. Each up-step
by 1 corresponds to a student in the old classes, and each down-step by 1 to a
student in the new classes.
We can use a link from any up-step of 1 to any preceding down-step of 1 to
identify each student in one assignment with one in the other. Our claim can be
verified by matching each up-step to a preceding down-step between the same
two levels (when there is one). The only students unmatched are the first ones
to reach each of the 𝑡 levels from 1 up to the maximum level reached, namely 𝑡.
Now for each of the 𝑡 positive levels there is a final down-step from that to the
preceding level. The 𝑡 unmatched up-steps can then be matched arbitrarily to
these final down-steps to complete the determination of which students in the
old correspond to which in the new class assignments; and the only students
reassigned to larger classes were those last 𝑡 to be matched.
We are now ready to prove our main result.

Theorem 12.2. Let 𝒫 and 𝒬 be partitions of 𝑆 such that 𝒫 has 𝑘 more blocks than
𝒬, and suppose that no block size occurs in both partitions. Then the number of
elements in larger blocks in 𝒬 than in 𝒫 is at least the sum 𝛾 of the sizes of the 𝑘+1
smallest blocks in 𝒫.

Proof. We prove a slightly stronger result. The sequence 𝑀 from Lemma 12.1
can be reduced by eliminating pairs of blocks, one from 𝒫 and one from 𝒬, of
the same size, so that there are no block sizes common to both. The removal of
Michael L. Fredman, Daniel A. Kleitman, and Peter Winkler 127

such pairs does not affect the largest partial sum. Reducing 𝑀 in this manner
correspondingly also reduces 𝒫 and 𝒬. We show:
The number of elements in larger blocks in 𝒬 than in 𝒫 is at (*)
least the sum 𝛾′ of the 𝑘+1 smallest blocks in the reduced 𝒫.
From now on assume 𝑀 has been reduced as described above. Let 𝜎 denote
the sequence of signs of 𝑀; that is, 𝜎 is the result of replacing each entry of 𝑀
with 1, but retaining its sign. The partial sums of 𝜎 start at 0 and end at 𝑘, since
there are 𝑘 more old classes than new ones. Let 𝐻 denote this sequence of partial
sums, and visualize 𝐻 as a histogram. Of interest is an interval of positions in 𝜎
(possibly empty), where the histogram of 𝐻 leaves off from and ends at the same
level 𝑡, so that the sum of 𝜎 over this same interval is 0. When the histogram
across this interval does not exceed level 𝑡 (we refer to this stretch as a level-
sided valley), then the up-steps and down-steps can be paired, with the paired
up-step on the right, implying that the sum of the corresponding entries of 𝑀
is nonnegative. Moreover, when the level valley is nonempty, the sum of the
corresponding entries of 𝑀 will be strictly positive since the successive terms of
𝑀 (now reduced) of differing signs have increasing magnitudes. Thus, the partial
sum of 𝑀 up to where 𝐻 reaches its peak value 𝑝 (say) is at least the sum of
the 𝑝 class sizes at the corresponding locations where 𝐻 reaches its 𝑝 successive
new highs—since between any consecutive new highs of 𝐻 there is a level-sided
valley.
Now we argue that 𝐻 reaches a peak of at least 𝑘+1. The total sum of 𝜎 (final
value of 𝐻) is 𝑘, while that of 𝑀 is 0. Consider the stretch of 𝐻 following its peak
level 𝑝 to its final position. If 𝑝 = 𝑘, then the number of negative and positive
terms in 𝐻 (and in 𝑀 as well) after this peak must be the same, and at no middle
point can the number of positive terms before it exceed the number of negative
ones. This means that this region must be a level-sided valley and the sum of 𝑀
over this stretch cannot be negative. But its sum must be minus the sum of 𝑀
at its start, which sum is at least the sum of the 𝑝 class sizes occurring where 𝐻
reaches its new highs. This is a contradiction.
Here is an example of sizes for 𝑘 = 1 in which the bound of 2 on the num-
ber moving to larger classes can be realized: Old sizes are (1, 1, 5, 5); new ones,
(4, 4, 4).
Another relevant question here is, When will the number of students moving
to larger classes strictly exceed the sum 𝛾 of the 𝑘+1 smallest block sizes of 𝒫?
We describe two (nonexhaustive) cases under which this happens.
(1) If there is a new class size smaller than the (𝑘+1)-st smallest old class size
(before reducing 𝑀), then the number of students moving to larger classes
strictly exceeds 𝛾.
128 Chapter 12. Generalization of a Puzzle Involving Set Partitions

(2) If there is no single new class having size that is at least the sum 𝛾′ of the
𝑘+1 smallest old class sizes (after reducing 𝑀), then the number of students
moving to larger classes strictly exceeds 𝛾′ .
To prove claim (1), let 𝑥 be the size of the smallest class size in 𝒬, and let 𝑦
be the size of the smallest class in 𝒫 that is greater than 𝑥. If 𝑥 is not present in
𝒫, then the histogram of 𝐻 has a nonempty level-sided valley spanning at least
across the positions corresponding to the consecutive values −𝑥 and 𝑦 in 𝑀. Its
contribution to the partial sum of 𝑀 is strictly positive, as discussed in the pre-
ceding proof, implying that the bound 𝛾 is strictly exceeded. But if 𝑥 is present
in 𝒫, then there is (at least) one less occurrence of 𝑥 in 𝒫 after it is reduced than
beforehand. Because 𝑥 is smaller than the (𝑘+1)-st old class size, we find that
the sequence of the smallest 𝑘 + 1 class sizes in the reduced 𝒫 strictly (in at least
one position) dominates the corresponding sequence before the reduction, and
the claim follows from (*).
Two examples: First, the old sizes are (2, 2, 2) and the new sizes are (1, 5), so
that 5 rather than 4 students move to larger classes. The level-sided valley over
the locations of the terms −1, 2 in 𝑀 accounts for the increase over the bound 4
inferred from property (*). Second, the old class sizes are (1, 2, 2) and the new
sizes are (1, 4). The sequence of the two smallest old class sizes (2, 2) after reduc-
tion strictly dominates the corresponding sequence (1, 2) before reduction.
We leave to the reader the proof of an analogous claim:
(1′ ) With respect to the reduced 𝑀, 𝒫, and 𝒬, if there is a new class size smaller
than the (𝑘+1)-st smallest old class size, then the number of students moving
to larger classes strictly exceeds the sum 𝛾′ of the 𝑘+1 smallest old class sizes.
We prove claim (2) by referring to the proof of Theorem 12.2. Suppose we
ignore the largest class size, 𝑥, in 𝒬. Then the sum of 𝑀 over all other class sizes
is 𝑥, and the final value of 𝐻 is 𝑘+1 without that class. Since the assumption here
is that 𝑥 is less than the partial sum of 𝑀 at the position where 𝐻 reaches its peak
𝑝, the sum of 𝑀 beyond that point must be negative, and the argument in the
proof implies here that 𝑝 must be strictly greater than 𝑘+1, just as it previously
implied that 𝑝 was greater than 𝑘.
There is an example illustrating the second claim where 𝑘 = 1. The old sizes
are given by (6, 6, 6), and the new sizes by (9, 9), each < 12, so that 18 (the sum of
the three smallest old sizes) instead of 12 (the sum of the two smallest old sizes)
students move to larger classes.
It follows from the claims above that the bound 𝛾 will be reached only if the
maximum partial sum 𝐻 is 𝑘+1, the smallest new class size is at least as large
as the (𝑘+1)-st smallest old class size, and the largest new class in the reduced
sequence has size 𝑦 ≥ 𝛾. If 𝑦 is the largest class size of all, then 𝑦 must be exactly
𝛾. We leave proof of this last statement to the reader.
Michael L. Fredman, Daniel A. Kleitman, and Peter Winkler 129

Comment
A relevant question is, How hard is it to find a new distribution of students to
classes, given an old one and a set of sizes of the new classes that meets the lower
bound implied by the lemma?
We can answer this as follows. The sequence 𝑀 can be divided into positive
blocks and negative blocks, a block being a consecutive sequence of entries of the
same sign. Then the students in each positive block starting with the first should
be assigned to positions in previous negative blocks in any way, until either that
block or the previous negative blocks are exhausted; then one does the same thing
for the next positive block, and continues until the last. Any resulting assignment
will leave the minimum number of students unassigned, and they can be assigned
to larger classes in an arbitrary way.
13
A Generalization of Retrolife
Yossi Elran

The Game of Life is one of the most well-known recreational mathematics top-
ics and is the forerunner of many more general cellular automata that have been
simulated on computers. This one-player game was invented by John Conway
(Berlekamp et al., 2003) in the early 1970s and popularized in a series of articles
written by Martin Gardner (Gardner, 1983). The basic idea of the game is to ap-
ply a set of rules to an initial distribution of tokens placed on an infinite square
grid of cells, at most one token per cell, creating a new distribution. Each distri-
bution of tokens is referred to as a “generation”. A cell with a token is termed a
“live” cell, and an empty cell is a “dead” cell. Applying the rules simultaneously
to a given generation means, in practice, the removal of tokens from some of the
cells (“death”) and placing tokens in others (“birth”). Some of the tokens remain
untouched; these are “survivors”. The outcome of this procedure is the appear-
ance of a new generation on the board. As this process continues interesting
“life-forms” emerge.
The original rules that Conway suggested are straightforward. The fate of
each cell on the board is determined according to the configuration of its eight
neighboring cells (in directions north, south, east, west, northeast, northwest,
southeast, and southwest). Instead of using the usual term “neighboring” cells,
we use from here on the phrase “surrounding” cells for reasons that will become
apparent later on.

131
132 Chapter 13. A Generalization of Retrolife

Conway’s three rules are the following.


• A token is removed from a live cell that is surrounded by fewer than two, or
more than three, live cells.
• If a live cell is surrounded by either two or three tokens, the token in the cell
remains untouched.
• A token is placed in an empty cell if exactly three live cells surround it.
Figure 13.1 shows three consecutive generations of Life, from left to right.

Figure 13.1. Three generations of the Game of


Life. (Elran, 2012). © Mathematical Association of
America, 2012. All rights reserved.

Since its inception, the amount of research on the Game of Life has exploded.
An excellent review is given in (Adamatzky, 2002).
“Retrolife” is the name of a puzzle we introduced at the seventh Gathering
4 Gardner conference (G4G7), held in Atlanta in 2006 (Elran, 2006). The aim
of the puzzle is to find predecessors for a given generation of the Game of Life;
for example, given the middle pane in Figure 13.1, deduce that its predecessor
was the pane on the left. Since the number of predecessors of any generation is
infinite, some extra constraints are introduced.
One constraint that we studied is as follows: Given a generation 𝑔, find its
predecessor given that all live cells in generation 𝑔 are dead in generation 𝑔 − 1.
The player is also required to provide the solution with the minimal number of
live cells. A typical Retrolife puzzle and its solution are presented in Figure 13.2.
Since its introduction, a few Retrolife challenges have been published
(Ashbacher, 2007; Elran, 2008, 2012). The rather cumbersome presentation of
the problem requires prior knowledge of the Game of Life. One way to overcome
this is to reframe the problem in the following manner. We begin with an infi-
nite grid or board and some black and white tokens. Each cell on the board can
Yossi Elran 133

Figure 13.2. A Retrolife puzzle: generation 𝑔 is in


the left pane, and its solution at generation 𝑔 − 1 is
in the right pane.

contain either a white token, a black token, or the cell may be empty. An ini-
tial pattern is placed on the board using one color of tokens. For convenience
we assume the pattern is created using white tokens. The generic puzzle is this:
“Surround each white token on the board with 𝑡 black tokens so that each black
token is not surrounded with 𝑛 black tokens and each empty square on the board
is not surrounded by 𝑒 black tokens, where 𝑡, 𝑛, and 𝑒 denote sets of whole num-
bers between 1 and 8.”
A formidable challenge is to find the minimum number of black tokens that
can be used. The original Retrolife problem is described using the parameters:
𝑡 = {3}, 𝑛 ≠ {2, 3}, and 𝑒 ≠ {3}.
The equality and inequality signs denote permitting or forbidding the sur-
rounding of cells by the specified number of tokens, respectively, and the comma
is to be understood as the logical OR operation. Figure 13.3 shows a very simple
puzzle of a linear pattern of three white tokens and a possible solution.
Changing the parameters of a Retrolife puzzle even slightly can sometimes
substantially increase the difficulty of finding a solution. For example, if we
change the restriction 𝑒 ≠ {3} in the previous puzzle to 𝑒 ≠ {2}, the solution
is no longer valid, since four of the empty cells are now surrounded by two to-
kens, and this is forbidden. Additional tokens need to be added to the board to
rectify this. Figure 13.4 shows this generalized Retrolife puzzle and a possible
(not proven to be minimum) solution (the parameters are: 𝑡 = {3}, 𝑛 = {2, 3}, and
𝑒 ≠ {2}).
Applying the Game of Life rules to the solution of this problem will not gener-
ate the puzzle board because the rules here differ from the classic Retrolife rules;
134 Chapter 13. A Generalization of Retrolife

Figure 13.3. A Retrolife puzzle in the left pane,


and its solution in the right pane

Figure 13.4. Another Retrolife puzzle and its solu-


tion

however, the initial puzzle will be recovered using the inverse of these rules. In
general, inverting Retrolife rules leads to different classes of cellular automata.
Retrolife can be further generalized by varying the topology of the board. Dif-
ferent tessellations of the plane can be used to form different boards, including
irregular, semiregular, periodic, aperiodic and quasi-periodic tessellations. The
fact that different polygons may form the board does not impair the game in the
slightest, as long as the 𝑡, 𝑛, and 𝑒 restrictions are never larger than the number of
sides of the smallest polygon in the tessellation. Figure 13.5 challenges the reader
Yossi Elran 135

Figure 13.5. Two Retrolife puzzles on unusual


boards

to solve two puzzles: Hex Retrolife, played on a hexagonal board, and Gridline
Retrolife, played on the gridlines of a regular square board (solutions in Figure
13.7).
Although Retrolife is a solitaire puzzle, it can be posed as a two-player game.
The simplest such game is for the players to pose a Retrolife puzzle for each other.
Both players have their own board and a set of black and white tokens. At the
beginning of the game, each player creates a shape with a predetermined number
of white tokens on his board. Then the players have to surround each other’s
shape with the minimal number of tokens possible according to predetermined
(𝑡, 𝑒, and 𝑛) Retrolife rules. The player who accomplishes this with the least
number of tokens wins. The game can also be played using the same initial shape,
decided upon by both players.
Another two-player game can be played, this time using one board. An ini-
tial shape is decided upon, for example the 𝐿-pentomino, and the shape is formed
on the board using white tokens. The aim of the game is to surround the white
tokens according to the predetermined (𝑡, 𝑒, and 𝑛) Retrolife rules. The winner is
the player that places the last token necessary to complete the game. It is forbid-
den to place a token in a position that eliminates all possible solutions. Needless
to say, the initial shape has to be, in principle, solvable.
Figure 13.6 shows the state of such a two-player game where the rules of the
game are 𝑡 = {3}, 𝑛 ≠ {2, 3}, and 𝑒 ≠ {3}. What move can the next player make to
win the game? (Solution in Figure 13.8.)
Retrolife and similar puzzles pose the interesting challenge of surrounding
one group of entities with another, according to specific rules that address each
136 Chapter 13. A Generalization of Retrolife

Figure 13.6. In this two-player Retrolife game,


what is the winning move?

member of the entity separately. The Japanese game of GO is such a puzzle, and
it is of interest to explore possible connections between the two games.
It is also of interest to study other questions that Retrolife raises. Does an
effective winning strategy exist? What other classes of puzzles are connected to
Retrolife? Are there any real life situations that may be simulated as Retrolife puz-
zles? Further research is indeed welcome, however just solving Retrolife puzzles
with pencil and paper is just as enjoyable and challenging!

Figure 13.7. Solutions for two Retrolife puzzles on


unusual boards.
Yossi Elran 137

Figure 13.8. Winning move for the two-player


game in Figure 13.6 (grey token)

Further Reading
A. Adamatzky, editor (2002). Game of Life cellular automata. Springer-Verlag,
London. http://public.eblib.com/choice/publicfullrecord.aspx?
p=646037.
C. Ashbacher (2007). Retrolife generation of the twelve pentominoes. Journal of
recreational mathematics., 36 (1): 35.
E. R. Berlekamp, J. H. Conway, and R. K. Guy (2003). Winning ways, for your
mathematical plays, volume 2. A. K. Peters, London; New York.
Y. Elran (2006). G4G7 Exchange Book.
Y. Elran (2008). Homage to a Pied Puzzler. A. K. Peters.
Y. Elran (2012). Retrolife and the pawns? neighbors. The College Mathematics
Journal, 43(2): 147–151.
M. Gardner (1983). Wheels, life, and other mathematical amusements. Freeman,
W. H., New York.
14
Coins
of Three Different Weights
Tanya Khovanova
Konstantin Knop

14.1 Introduction
We discuss several coin-weighing puzzles. Here is the setup for all of them.
There are 𝑛 coins that look the same, but they have different weights. The
number of different possibilities for their weights is three. The pans are
one of two types: tiny (allow only one coin) or huge (allow any number
of coins). Use the balance scale the fewest number of times for one of
two goals: sort the coins into their weights or find a particular coin.
There is a lot of literature in the case when there are two different weights.
In this case usually one weight is designated as real and the other as counterfeit.
We cannot possibly cover all available articles on the subject, so we just list some
of them.
The first publication was by E. D. Schell in the January 1945 issue of the
American Mathematical Monthly (Schell, 1945). It discussed a problem of find-
ing one fake coin that is lighter than real coins out of nine coins total. The prob-
lem of one fake coin out of twelve coins when it is not known whether the fake

139
140 Chapter 14. Coins of Three Different Weights

coin is heavier or lighter appeared almost at the same time (Eves, 1946). The solu-
tion generated a lot of publications (Descartes, 1950; Goodstein, 1945; Grossman,
1945).
The generalization of the latter puzzle for any number of coins is covered in
(Dyson, 1946; Fine, 1946). There is also a variation where we need to find the
fake coin, but do not need to tell whether is it heavier or lighter (Dyson, 1946;
Mauldon, 1978).
In (Pyber, 1986; Aigner and Li, 1997) bounds close to log3 𝑛 were found for
finding the fake coins if the number of fake coins is limited by a small fixed num-
ber. The case when we do not know the number of fake coins is covered by (Hu
et al., 1994; Purdy, 2011).
A set of papers were written to answer the question of whether or not all
the coins are of the same weight (Alon et al., 1996; Alon and Vũ, 1997; Alon and
Kozlov, 1997; Kozlov and Vu, 1997). Another direction of this problem is when
you are allowed to use several balance scales in parallel (2012 Ukraine-Russian
Puzzle Tournament, 2016; Knop, 2013; Khovanova, 2013b).
A survey of coin-weighing problems was written by R. K. Guy and R. J. No-
wakowsky (Guy and Nowakowski, 1995) and a classification of different coin-
weighing problems by E. Purdy (Purdy, 2011).
We did not find papers discussing three different weights in a general setting.
We only found some puzzles in the book by J. C. Baillif (Baillif, 1982).
Throughout the paper we define sorting of the coins as partitioning of the
coins into groups, where the coins in each group weigh the same, the coins in
different groups have different weights, and for every two groups we know which
one contains lighter coins. We start with general theory in Section 14.2. Then we
discuss particular problems:
• Section 14.3: Pans are tiny, the number of possible weights is 2, the goal is to
sort. We prove that the number of weighings is not more than 𝑛 − 1 and at
least ⌈𝑛/2⌉.
• Section 14.4: Pans are tiny, the number of possible weights is 3, the goal is to
sort. We prove that sorting can be done in not more than ⌈3𝑛/2⌉−2 weighings,
and it is impossible to guarantee fewer weighings.
• Section 14.5: Pans are huge, the number of possible weights is 3, the goal is
to sort. Additional constraint: one coin is of middle weight. We prove that
the coins can be sorted in 𝑛 weighings.
• Section 14.6: Pans are huge, the number of possible weights is 3. Additional
constraint: one coin is of middle weight. The goal is to find the middle coin.
We prove that the middle-weight coin can be found in ⌈𝑛/2⌉ + log3 𝑛 weigh-
ings.
Tanya Khovanova and Konstantin Knop 141

• Section 14.7: Pans are huge, the number of possible weights is 3, the goal is
to sort. We prove that the coins can be sorted in 𝑛 + 1 weighings.

14.2 General Theory


Suppose we have 𝑛 coins of three different weights 𝑤1 , 𝑤2 , and 𝑤3 , where 𝑤1 <
𝑤2 < 𝑤3 . The total number of different possibilities of assigning these weights
to coins is 3𝑛 . We cannot always differentiate some of these possibilities using
just a balance scale. For example, if all the coins are of the same weight, there is
no way to decide whether this weight is 𝑤1 , 𝑤2 , or 𝑤3 . The number of different
possibilities that are distinguishable by a balance scale is known to be 3𝑛 −2⋅2𝑛 +2;
see sequence A101052 in the On-Line Encyclopedia of Integer Sequences (OEIS)
(Sloane, 2010): 1, 3, 13, 51, 181, . . . .
Each weighing divides the space of possibilities into three parts: the coins in
both pans weigh the same, the coins in the left pan are lighter, and the coins in
the left pan are heavier. For optimality we want these parts to be of equal or close
to equal sizes. The lower bound follows:

Lemma 14.1. For 𝑛 > 2, the number of needed weighings is at least 𝑛.

Proof. It is enough to see that 3𝑛 − 2 ⋅ 2𝑛 + 2 > 3𝑛−1 , for 𝑛 > 2.


For 𝑛 = 1, we do not need any weighings. For 𝑛 = 2, comparing the two
coins to each other is the only weighing that is needed.
For 𝑛 > 2, we argue that the most profitable use of the scale for the first
weighing is to compare one coin against one coin. For simplicity, we assume that
the weights 𝑤1 , 𝑤2 , and 𝑤3 are linearly independent over integers. That means
if the scale balances with 𝑘1 coins on the left pan and 𝑘2 coins on the right pan,
then 𝑘1 = 𝑘2 , and the partition of coins into different weights is the same for both
pans.
Suppose we pick two coins, 𝑎 and 𝑏, that we did not weigh yet and compare
them against each other. If 𝑎 is lighter than 𝑏, then the possibilities of the weight
distributions for these two coins are (𝑤1 , 𝑤2 ), (𝑤1 , 𝑤3 ), and (𝑤2 , 𝑤3 ). Similarly, if
𝑎 is heavier than 𝑏, then the possibilities are (𝑤2 , 𝑤1 ), (𝑤3 , 𝑤1 ), and (𝑤3 , 𝑤2 ). If 𝑎
and 𝑏 weigh the same, then we have (𝑤1 , 𝑤1 ), (𝑤2 , 𝑤2 ), and (𝑤3 , 𝑤3 ). That means
at the beginning, when we do not have any more information, comparing pairs
of coins is effective: it divides the space of possibilities into three equal parts.
We will show that using more coins in the first weighing divides the space less
equally.
Let us see what happens if instead of comparing one coin to one coin, we
compare two coins against two coins. By symmetry, the two unbalanced out-
comes divide the space of possibilities equally. Now we count the number of
142 Chapter 14. Coins of Three Different Weights

possibilities if the pans are balanced. If the two coins on the left pan are of the
same weight, then the total weight on each pan is 2𝑤1 , 2𝑤2 , or 2𝑤3 . For each
of these total weights all four coins are uniquely determined. So there are three
possibilities.
Now suppose the two coins on the left pan are of different weights, for a total
of 𝑤1 + 𝑤2 , 𝑤1 + 𝑤3 , or 𝑤2 + 𝑤3 . Then the left and the right pan have the same
distribution of coins, but we can interchange the two coins in each pan. Thus for
every total weight we have four possibilities. So there are twelve possibilities.
The total number of possibilities for the weights when the pans are balanced
is 15, which is less than 27—the desired third of all possibilities of weights of four
coins.
Thus comparing two coins against two coins is not as good a strategy as com-
paring one coin against one coin. Now we generalize this observation to more
than two coins.
𝑘 2
Theorem 14.2. If 𝑘 coins on each side balance, there are ∑𝑖 = 0 (𝑘) (2𝑖) possibilities
𝑖 𝑖
for the distribution of weights among these 2𝑘 coins.

Proof. For each partition of 𝑘 into three nonnegative integers 𝑘1 , 𝑘2 , and 𝑘3 ,


where 𝑘1 + 𝑘2 + 𝑘3 = 𝑘, the number of possibilities is
2 2 2
𝑘! 𝑘 𝑘 − 𝑘1
( ) =( ) ( ) .
𝑘1 ! 𝑘2 ! 𝑘3 ! 𝑘1 𝑘2
The formula for the sum of squares of binomial coefficients is well known (Spiegel,
1998):
𝑚 2
𝑚 2𝑚
∑ ( ) = ( ).
𝑖=0
𝑖 𝑚
Thus, the total is
2 2 𝑘1
2 𝑘−𝑘 2
𝑘 𝑘 − 𝑘1 𝑘 𝑘 − 𝑘1
∑ ( ) ( ) = ∑ ( ) (∑ ( ) )
𝑘1 +𝑘 +𝑘 =𝑘
𝑘1 𝑘2 𝑘 =0
𝑘1 𝑘 =0
𝑘2
2 3 1 2

𝑘 2 𝑘 2
𝑘 2(𝑘 − 𝑘1 ) 𝑘 2𝑖
= ∑ ( ) ( ) = ∑ ( ) ( ).
𝑘 =0
𝑘1 (𝑘 − 𝑘1 ) 𝑖=0
𝑖 𝑖
1

With three coins (𝑘 = 3) in each pan, assuming linear independence of the


three weights, we get 93 possibilities for balancing; for four coins we get 639 pos-
sibilities. This is the sequence A002893 in the OIES. Let 𝑎𝑛 denote the num-
ber of possibilities for the weights when we weigh 𝑛 coins against 𝑛 coins and
they balance. The total number of possibilities for the weights of 2𝑛 coins is
32𝑛 . Let 𝑝𝑛 = 𝑎𝑛 /32𝑛 be the ratio. We already saw that 𝑝1 = 1/3 ≈ 0.333,
𝑝2 = 15/81 ≈ 0.185, 𝑝3 = 93/729 ≈ 0.128, and so on.
Tanya Khovanova and Konstantin Knop 143

Theorem 14.3. The sequence 𝑝𝑛 decreases.

Proof. We can show that 𝑎𝑛+1 < 9𝑎𝑛 . As 𝑎1 = 3 and 𝑎2 = 15, this is true for
𝑛 = 1. We proceed by induction using the recurrence for 𝑎𝑛 (Sloane, 2010):
(𝑛 + 1)2 𝑎𝑛+1 = (10𝑛2 + 10𝑛 + 3)𝑎𝑛 − 9𝑛2 𝑎𝑛−1 .
Let 𝑎𝑛 < 9𝑎𝑛−1 . Then
(𝑛 + 1)2 𝑎𝑛+1 = (10𝑛2 + 10𝑛 + 3)𝑎𝑛 − 9𝑛2 𝑎𝑛−1
< (10𝑛2 + 10𝑛 + 3)𝑎𝑛 − 𝑛2 𝑎𝑛
= (9𝑛2 + 10𝑛 + 3)𝑎𝑛 < 9(𝑛 + 1)2 𝑎𝑛 .
Thus, 𝑎𝑛+1 < 9𝑎𝑛 . From this, 𝑝𝑛+1 = 𝑎𝑛+1 /9𝑛+1 < 𝑎𝑛 /9𝑛 = 𝑝𝑛 .
Since 𝑝1 = 1/3, we see that 𝑝𝑛 < 1/3, for 𝑛 > 1. This result allows us to
formulate the following rule.

Rule. It is a good idea to start weighings by comparing one coin against one coin.

Our reasoning applies not only to the first weighing: If there are two coins
that have not been weighed yet, then comparing one against the other does not
contradict potential optimality.

General Rule. It is a good idea to compare two coins that have not been weighed
yet.

Most coin-weighing problems assume that the capacity of each pan is unlim-
ited. But we see that, at least at the beginning, we do not need this capacity; we
just need to fit one coin.
We define huge pans as pans with an unlimited capacity and tiny pans as
pans that only fit one coin.
Because of the importance of tiny pans, we start our study with them. After
that we use our findings and methods for huge pans.

14.3 Tiny Pans. Two Weights. Sort


As a warm-up we will cover the sorting problem with tiny pans and two different
weights.
There are 𝑛 > 1 coins that look the same, but they are either real or fake.
Real coins all weigh the same. Fake coins weigh the same as each other,
but they are lighter than real coins. The balance scale allows only one
coin on each pan. Use the balance scale the smallest number of times to
sort the coins by weight.
144 Chapter 14. Coins of Three Different Weights

Theorem 14.4. The optimal number of required weighings is not more than 𝑛 − 1
and at least ⌈𝑛/2⌉.

Proof. Pick a coin and compare it to all other coins one by one. This strategy
allows us to sort the coins in 𝑛 − 1 weighings. On the other hand, each coin
needs to be put on the scale, and each weighing uses two coins. That means we
need at least ⌈𝑛/2⌉ weighings.
Suppose we have 𝑛 coins and the first weighing of two coins is unbalanced. In
this case we sorted these two coins in one weighing, and the problem is reduced
to 𝑛−2 coins. On the other hand, suppose the weighing is balanced. Then we can
put aside one of the coins, but we have to compare the other coin to something
else to figure out whether these are the heavy coins or the lighter ones. After the
first weighing we reduced the problem to 𝑛 − 1 coins.
So the actual number of weighings depends on how many times we get an
unbalanced weighing in the process. For example, if all coins weigh the same,
then every weighing is balanced. In this case any algorithm will require 𝑛 − 1
weighings to sort the coins.

14.4 Tiny Pans. Three Weights. Sort


Now let us go back to our main goal and consider three weights.
There are 𝑛 coins that look the same, but they have different weights. The
number of different possibilities for their weights is three. The balance
scale allows only one coin on each pan. Use the balance scale the fewest
number of times to sort the coins.
We will show that sorting can be done in ⌈3𝑛/2⌉−2 weighings, and it is impos-
sible to guarantee fewer weighings. First let us produce a strategy that requires
not more than ⌈3𝑛/2⌉ − 2 weighings.

Theorem 14.5. There is a strategy that requires not more than ⌈3𝑛/2⌉−2 weighings.

Proof. The strategy consists of three rounds. Before the first round we mark all
coins as 𝑈 (meaning unknown).
We start by comparing two coins. If they are not balanced, we mark the
lighter coin as 𝐿 and the heavier as 𝐻. If two coins balance, we put one of them
aside, removing its mark, and return the other one to the pile of coins marked 𝑈.
For every coin put aside we keep track of which coin it balanced with.
We keep weighing pairs of coins marked 𝑈 until at most one coin is left, at
which point the first round ends. After the end of the round we have:
• two piles of the same size—one from the lighter pan marked 𝐿 and the other
from the heavier pan marked 𝐻;
Tanya Khovanova and Konstantin Knop 145

• maybe one extra coin marked 𝑈;


• some coins set aside, and the weight of each set-aside coin matches one of
the marked coins.
Note that in the first round a balanced weighing is profitable. The set-aside
coins do not need to participate in later rounds: Their fate is decided with one
weighing per coin, which is better than our goal of 1.5 weighings per coin. Hence
we can assume the worst, that all the weighings in the first round are unbalanced.
In the worst case we have two piles of size ⌊𝑛/2⌋ at the end of the first round.
The first pile has only lighter and middle-weight coins, and the second pile has
only heavier and middle-weight coins. Also, we might have one extra coin we
know nothing about.
In the second round we process the lighter pile and the heavier pile sepa-
rately. By Theorem 14.4 we need not more than ⌊𝑛/2⌋ − 1 weighings to process
the pile from the lighter pan and the same number of weighings to process the
heavier pile.
As we are assuming that all the weighings are unbalanced in the first round,
we can get the extra coin only if 𝑛 is odd. The third round is devoted to processing
the extra coin. If by this time we have piles of three different weights, we can
compare the last coin to a middle-weight coin and establish its weight. If by this
time we have piles of only two different weights, we need to compare the extra
coin to one coin from each of the other two piles and thus establish to which
weight each pile belongs.
Summing up ⌊𝑛/2⌋ for comparing unknown coins (the first round) and
2(⌊𝑛/2⌋ − 1) for sorting coins in the heavier and lighter piles (the second round)
and 2 for the extra coin if the number of coins is odd (third round), we get 3𝑛/2−2
for even 𝑛 and 3⌊𝑛/2⌋ for odd 𝑛. We can combine this to ⌈3𝑛/2⌉ − 2 for any 𝑛.
Let us prove that this strategy is one of the optimal ones.

Theorem 14.6. We cannot guarantee sorting in fewer than ⌈3𝑛/2⌉ − 2 weighings.

Proof. Consider an adversary who can control the outcome of each weighing and
wishes to increase the number of weighings. Here is the adversary’s strategy. At
every point in the weighing process the adversary labels each coin by one of the
letters 𝑈, 𝐿, and 𝐻.
• 𝑈—the coin did not participate in any weighing yet.
• 𝐿—the coin participated in weighings and was lighter.
• 𝐻—the coin participated in weighings and was heavier.
146 Chapter 14. Coins of Three Different Weights

The adversary chooses the outcome of every weighing by the following rules:
(1) 𝑈 < 𝑈—Two 𝑈 coins are always unbalanced.
(2) 𝑈 > 𝐿—The 𝑈 coin is always heavier than an 𝐿 coin.
(3) 𝑈 < 𝐻—The 𝑈 coin is always lighter than an 𝐻 coin.
(4) 𝐿 < 𝐻—An 𝐿 coin is always lighter than an 𝐻 coin.
(5) 𝐿 = 𝐿—Two 𝐿 coins always balance.
(6) 𝐻 = 𝐻—Two 𝐻 coins always balance.
The rules are chosen to maximize the number of weighings. For example,
if our strategy requires comparing two 𝑈 coins, then it is not profitable for the
adversary to balance them, so the adversary makes one of them, say left, be lighter
than the other.
This adversary’s strategy guarantees that the labeling is consistent. A coin in
group 𝐿 is never heavier than another coin, and similarly for group 𝐻.
Let us define the equality graph of the group marked 𝐿. Each vertex of the
graph corresponds to a coin labeled 𝐿. The vertices are connected if there was a
weighing where the corresponding two coins were of equal weight. The number
of connected components symbolizes how many coins in group 𝐿 we need to sort.
Similarly, we define the equality graph for the 𝐻 group.
The adversary keeps track of three numbers:
• 𝑢—the total number of coins marked as 𝑈.
• 𝑙—the number of connected components in the equality graph of the group
labeled 𝐿.
• ℎ—the number of connected components in the equality graph of the group
labeled 𝐻.
At the beginning all coins are of type 𝑈, and the corresponding triple of num-
bers (𝑢, 𝑙, ℎ) is (𝑛, 0, 0).
After the 𝑈 < 𝑈, weighing the lighter coin will be marked as 𝐿 but it has not
been compared to any other 𝐿 coins, so the number of connected components in
𝐿 increases by 1. Suppose before the weighing the numbers were (𝑢, 𝑙, ℎ), then
after the weighing they become (𝑢 − 2, 𝑙 + 1, ℎ + 1). Similarly, we can process
what happens to the triple of numbers (𝑢, 𝑙, ℎ) after a weighing of each of the six
types above. All the results are combined in Table 14.1.
Note that if the strategy requires us to compare two 𝐿 coins, then if they
were from the same connected component, the number of components does not
change. If they were from different components, the number of components de-
creases by 1. Similarly for two 𝐻 coins.
Tanya Khovanova and Konstantin Knop 147

Table 14.1. Results of different types of weighings

Type Weighing Result


1 𝑈<𝑈 (𝑢 − 2, 𝑙 + 1, ℎ + 1)
2 𝑈>𝐿 (𝑢 − 1, 𝑙, ℎ + 1)
3 𝑈<𝐻 (𝑢 − 1, 𝑙 + 1, ℎ)
4 𝐿<𝐻 (𝑢, 𝑙, ℎ)
5 𝐿=𝐿 (𝑢, 𝑙 − 1, ℎ) or (𝑢, 𝑙, ℎ)
6 𝐻=𝐻 (𝑢, 𝑙, ℎ − 1) or (𝑢, 𝑙, ℎ)

Consider the value 𝑠 = 1.5𝑢 + 𝑙 + ℎ. At the beginning we have only 𝑈 coins


and thus 𝑠 = 1.5𝑛. At the end we assume that the adversary stops fighting us
when the 𝑈 group becomes empty and the groups 𝐿 and 𝐻 each are divided into
two connected components. At this point 𝑠 = 4. Note that the only scenario when
we cannot reduce the 𝐿 and 𝐻 equality graphs to two connected components is
when we have exactly one 𝐿 and 𝐻 coin. In this case 𝑠 = 2.
Our weighings do not increase 𝑠. So to minimize the number of weighings,
we need to maximize the rate with which we decrease 𝑠.
Weighings of the first type decrease 𝑠 by 1. Weighings of type 5 or 6 decrease
it by 1 or 0. Weighings of type 2 or 3 decrease it by 0.5. Weighings of type 4 are the
least profitable for us: they do not change 𝑠 at all. The most profitable weighings
are of type 1, 5, and 6, and the strategy should not weigh the coins that are in the
same component of an 𝐿 or 𝐻 group. In any case, we cannot reduce 𝑠 faster than
by 1 for each weighing.
At the end, when the adversary stops controlling the weighing, if there are
two connected components in the 𝐿 and 𝐻 group, we need one more weighing
for each group to compare the components in that group. This is equivalent to
saying that at the end we need 𝑠 = 2.
Hence, the number of weighings is at least 1.5𝑛 − 2. As it is an integer, the
number of weighings is at least ⌈3𝑛/2⌉ − 2.
Note that the same method can be applied to any number of different weights,
say 𝑘, to reduce the problem to a smaller number of weights. Each reduction hap-
pens in one round. After the first round the coins will be marked 𝐿, 𝐻, and 𝑈.
In addition we will know that all the coins marked 𝑈 weigh the same, the coins
marked 𝐿 are not of the heaviest weight, and the coins marked 𝐻 are not of the
lightest weight.
We start by comparing two coins. If they are not balanced, we mark the
lighter coin as 𝐿 and the heavier as 𝐻. If two coins balance, we put one of them
aside, and return the other one to the pile of unknown coins. For every coin put
148 Chapter 14. Coins of Three Different Weights

aside we keep track of which coin it balanced with. If there is an extra coin, we
can use one more weighing to assign it to either the 𝐿 or the 𝐻 pile.
Note that we used ⌊𝑛/2⌋ + 1 weighings, and the coins in the 𝐿(𝐻) pile cannot
contain coins of the heaviest (lightest) weight.
After this round we have reduced the problem to two piles each having at
most 𝑘 − 1 different weights. In addition, we have some coins that are known to
be equal to a coin in one of the piles.
In the second round we can compare coins within 𝐿 and within 𝐻 by using
at most ⌊𝑛/2⌋ + 2 weighings. As a result we will get four new piles that we can
combine into three piles:
• 𝐿𝐿 does not contain coins of the two heaviest weights,
• 𝐿𝐻 and 𝐻𝐿 do not contain coins of the heaviest or the lightest weights,
• 𝐻𝐻 does not contain coins of the two lightest weights.
The next round will require at most ⌊𝑛/2⌋ + 3 weighings. Continuing in this
manner, after 𝑘 − 2 rounds we have divided our coins into 𝑘 − 1 piles each with
coins of two different weights. Overall we use at most (𝑘−2)⌊𝑛/2⌋+(𝑘−1)(𝑘−2)/2
weighings. After that we need at most 𝑛 − (𝑘 − 1) weighings to sort the piles of
two different weights each. The final bound is
(𝑘 − 2)⌊𝑛/2⌋ + (𝑘 − 1)(𝑘 − 2)/2 + 𝑛 − (𝑘 − 1)
= 𝑘⌊𝑛/2⌋ + (𝑛 − 2⌊𝑛/2⌋) + (𝑘 − 1)(𝑘 − 2)/2 − (𝑘 − 1)
≤ 𝑘⌊𝑛/2⌋ + 1 + (𝑘 − 1)(𝑘 − 4)/2.
Coin weighing with tiny pans is equivalent to sorting algorithms. Minimi-
zing the number of times the scale is used in coin problems is equivalent to min-
imizing the number of times the comparison operation is used in sorting algo-
rithms. The main difference is that when sorting, the standard assumption is that
the elements of the list are all different. Traditionally in coin-weighing problems,
the number of possible values for weights is very small. This extra assumption
creates room for improving on known sorting algorithms. The algorithm we de-
scribed above is a coin-weighing analogue of the Tournament sort (Wikipedia,
2016).

14.5 Huge pans. Three Weights. One Coin of the Middle


Weight. Sort
Suppose we have three weights, huge pans, and one coin of the middle weight.
There are 𝑛 coins that look the same, but they have different weights.
There are only three possibilities for their weights, and one coin is of the
middle weight. The balance scale allows any number of coins on each
pan. Sort the coins.
Tanya Khovanova and Konstantin Knop 149

First we solve the case when we have some extra information: For every coin
we know that it belongs to one of two classes:
• 𝐿: the coin is either lighter or middle weight.
• 𝐻: the coin is either heavier or middle weight.
In this case we can find the middle coin in ⌈log3 𝑛⌉ weighings.

Lemma 14.7. There are 𝑛 > 2 coins that look the same. But they have different
weights. There are only three possibilities for their weights. There is at least one coin
of each weight and exactly one coin of the middle weight. For every coin, it is known
which one of the two extreme weights it does not weigh. Then the coins can be sorted
in ⌈log3 𝑛⌉ weighings.

Proof. Suppose 3𝑘 < 𝑛 ≤ 3𝑘+1 . Divide all the coins into three piles 𝐴1 , 𝐴2 , and
𝐴3 , so that |𝐴1 | = |𝐴2 | and 3𝑘 ≥ max{|𝐴1 |, |𝐴2 |, |𝐴3 |}, where |𝐴𝑖 | is the size of the
pile 𝐴𝑖 . In addition, make sure that the number of 𝐿 and 𝐻 coins is the same in
piles 𝐴1 and 𝐴2 .
Now weigh 𝐴1 against 𝐴2 . If the weighing balances, then the middle-weight
coin is in 𝐴3 . If 𝐴1 is lighter, then the middle-weight coin is either one of the
coins marked 𝐿 in 𝐴2 , or one of the coins marked 𝐻 in 𝐴1 . In any case, we are
in the same situation as before, but the size of the pile that might contain the
middle-weight coin is reduced to not more than 3𝑘 .
At the very end we will have a pile of size not more than 3 containing the
middle-weight coin. If the size of the pile is 3, then comparing two coins marked
the same will reveal the middle-weight coin. If the size of the pile is less than 3,
we can add more coins to the pile to make it 3 and, as before, compare two coins
marked the same.
In this setup finding the middle-weight coin is equivalent to sorting.
Now we can get back to the original problem.

Theorem 14.8. If there is one middle-weight coin, then the coins can be sorted in
𝑛 weighings.

Proof. We start with the same method as in Theorem 14.5. We compare two coins
of unknown weights. If two coins are unbalanced, we sort them into two classes:
𝐿 and 𝐻. If two coins balance, we put one aside and the other back into the pile of
unknown coins. We continue this procedure until not more than one unknown
coin is left. If the 𝐿 and 𝐻 classes each contain 𝑘 coins, we performed 𝑘 + 𝑛 −
2𝑘 − 1 = 𝑛 − 𝑘 − 1 weighings. We compare the unknown coin, if any, to one of
the coins from the 𝐿 or 𝐻 class and assign the class value to it.
150 Chapter 14. Coins of Three Different Weights

After not more than 𝑛 − 𝑘 weighings, we have not more than 2𝑘 + 1 coins
marked 𝐿 and 𝐻 that need to be further processed, and they satisfy the assump-
tions of Lemma 14.7. Thus we can process them in ⌈log3 (2𝑘 + 1)⌉ ≤ 𝑘 weigh-
ings.
Note that the same method can be applied to a problem with three weights
where the number of coins of the middle weight is small. First we use the method
described in Section 14.4 and not more than 𝑛 weighings to separate coins into
two piles so that each pile has coins of two possible weights. Then we use one of
the known methods of finding the fake coins from a set of coins when the number
of fake coins is small (Pyber, 1986; Aigner and Li, 1997).

14.6 Find the coin of middle weight


In this variation instead of sorting the coins, we need to find the middle-weight
coin.
There are 𝑛 coins that look the same, but they have different weights.
There are only three possibilities for their weights, and exactly one coin
is of the middle weight. The balance scale allows any number of coins
on each pan. Find the middle-weight coin.

Theorem 14.9. The problem of finding the only middle-weight coin can be solved in
⌈𝑛/2⌉ + ⌈log3 𝑛⌉ weighings.

Proof. We start by using the method above of comparing pairs of two unknown
coins. We can discard pairs of coins of equal weight as they cannot contain the
middle-weight coin. After ⌊𝑛/2⌋ weighings we have a pile 𝐿 from the lighter pan
that can contain only the lighter coins or the middle-weight coin, a pile 𝐻 from
the heavier pan that can contain only the heavier coins or the middle-weight coin,
and possibly a leftover coin, which could be anything. If there is a leftover coin,
we can use one weighing to assign it either to 𝐿 or to 𝐻. Up to this point we used
⌈𝑛/2⌉ weighings.
Now we can apply Lemma 14.7 to find the middle coin out of the union of 𝐿
and 𝐻 coins in not more than ⌈log3 𝑛⌉ weighings.
This puzzle variation was inspired by a problem at the 2013 MIT Mystery
Hunt (Khovanova, 2013a). Every year MIT runs a mystery hunt, where many
teams compete in solving puzzles and finding a coin at the end. During the 2013
MIT Mystery Hunt the team designing the hunt, very appropriately, designed the
last puzzle as a coin-weighing puzzle:
There are nine coins that look the same, and only one of them is real. But
they have different weights. There are only three possibilities for their
Tanya Khovanova and Konstantin Knop 151

weights. Four coins are heavier and four coins are lighter than the real
coin. The balance scale allows any number of coins on each pan. Find
the real coin in not more than seven weighings.
Theorem 14.9 proves that the puzzle can be solved in seven weighings, and
it shows how to do it. Actually, it is possible to find the real coin in six weighings.
This is due to the facts that the number of coins of each weight is known and the
number of lighter and heavier coins is even. We leave it to the reader to find the
mysterious place to save one weighing.

14.7 Huge pans. Three Weights. Sort


Let us revisit the case of sorting three weights, but now with huge pans.
There are 𝑛 coins that look the same, but they have different weights. The
number of different possibilities for their weights is three. The balance
scale allows any number of coins on each pan. Use the balance scale the
fewest number of times to sort the coins.

Theorem 14.10. There is a strategy that requires no more than 𝑛 + 1 weighings.

Proof. The strategy consists of four rounds. The first round is similar to the first
round in Theorem 14.5. Before it we mark all coins as 𝑈.
Round 1. We start by comparing two coins. If they are not balanced, we mark
the lighter coin as 𝐿 and the heavier as 𝐻, and we keep track of this unbalanced
pair. If two coins balance, we put one of them aside, remove its mark, and return
the other one to the pile of coins marked 𝑈. For every coin put aside, we keep
track of which coin it balanced with. We keep weighing pairs of coins marked 𝑈
until at most one coin is left, at which point the first round ends.
Every balanced weighing reduces the number of coins we need to sort by one
and uses one weighing. After this round we will need to process only marked
coins (all but the set-aside coins).
At the end of this round we will have 𝑘1 marked coins. Out of them ⌊𝑘1 /2⌋
are marked 𝐿 (lighter or middle weight), ⌊𝑘1 /2⌋ are marked 𝐻 (heavier or middle
weight), and there may be an extra coin marked 𝑈. We have 𝑘1 + 1 − ⌊𝑘1 /2⌋ more
weighings we are allowed to use.
Round 2. Compare unbalanced pairs against each other until the two pans do
not balance. Suppose (𝑐1 , 𝑑1 ) is the first unbalanced pair, and (𝑐2 , 𝑑2 ) is the second
unbalanced pair. We denote the weight of a coin with the same letter as a coin.
Suppose 𝑐1 < 𝑑1 and 𝑐2 < 𝑑2 . Each unbalanced pair weighs 𝑤1 + 𝑤2 , 𝑤1 + 𝑤3 ,
or 𝑤2 + 𝑤3 . As 𝑤1 + 𝑤2 < 𝑤1 + 𝑤3 < 𝑤2 + 𝑤3 , comparing pairs give a lot of
information. Suppose the pair (𝑐1 , 𝑑1 ) balances against (𝑐2 , 𝑑2 ), then 𝑐1 = 𝑐2 and
𝑑1 = 𝑑2 . That means that two coins 𝑐2 and 𝑑2 can be put aside, removing their
152 Chapter 14. Coins of Three Different Weights

marks as each of them has a match. We used a total of two weighings for these
two put-aside coins, one in Round 1 and one in Round 2.
If all pairs balance and there is no extra coin, then all the coins are sorted in
𝑛 − 1 weighings. If there is an extra coin, we can use two weighings to compare
it to an 𝐿-coin and an 𝐻-coin and finish the sorting. In this case we need 𝑛 + 1
weighings.
Now we can assume that we found two pairs of coins that do not balance.
By this time we have 𝑘2 marked coins that we still need to process, and we have
𝑘2 − ⌊𝑘2 /2⌋ more weighings we are allowed to use.
Suppose 𝑐1 + 𝑑1 < 𝑐2 + 𝑑2 are the four coins that form two unbalanced pairs.
That means 𝑐1 = 𝑤1 and 𝑑2 = 𝑤3 . We can unmark these coins as we know their
weights. Now 𝑐1 and 𝑑2 becomes our reference pair.
Round 3. Compare the remaining pairs against the reference pair. We compare
the remaining unbalanced pairs against the reference pair. After such a weighing,
we know the weights of the coins in the nonreference pair, so we can remove
marks from them.
After we process all pairs, we will have some coins put aside that match other
coins, some coins of known weight, and in addition we will have the coins 𝑑1 and
𝑐2 , and maybe an extra coin. We only need to process 𝑑1 , 𝑐2 and the extra coin to
assign all the weights. If there is no extra coin, we have two more weighings we
can use. If there is an extra coin, we have three more weighings we can use.
We know that 𝑑1 is classified as 𝐻, and 𝑐2 as 𝐿. So we use one more weighing
to compare 𝑑1 against 𝑑2 . The latter is of weight 𝑤3 , so at the end of this weighing
we will know the weight of 𝑑1 . Similarly, we use one more weighing to find the
weight of 𝑐2 by comparing it against 𝑐1 .
Round 4. Compare the extra coin to a coin of the middle weight.
If there is an extra coin, we have one more weighing we are allowed to use.
We can determine the weight of the extra coin in one weighing by comparing it
to a middle-weight coin.
Notice that two unbalanced pairs guarantee us the existence of this middle-
weight coin. Indeed, the pairs (𝑐1 , 𝑑1 ) and (𝑐2 , 𝑑2 ) cannot both be of weight
𝑤1 + 𝑤3 . That means at least one of the coins 𝑐2 or 𝑑1 must be of the middle
weight 𝑤2 .

Acknowledgments
We are grateful to Julie Sussman, P.P.A., for thoroughly reading our drafts and
helping us clarify our presentation.
Tanya Khovanova and Konstantin Knop 153

Further Reading
2012 Ukraine-Russian Puzzle Tournament (2016). http://kig.tvpark.ua/
_ARC/2012/KG_12_38_12.PDF.
M. Aigner and A. Li (1997). Searching for counterfeit coins. Graphs and Combi-
natorics, 13(1): 9–20. DOI 10.1007/bf01202233.
N. Alon and D. N. Kozlov (1997). Coins with arbitrary weights. Journal of Algo-
rithms, 25(1): 162–176. DOI 10.1006/jagm.1997.0871.
N. Alon and V. H. Vũ (1997). Anti-Hadamard matrices, coin weighing, thresh-
old gates, and indecomposable hypergraphs. Journal of Combinatorial Theory,
Series A, 79 (1): 133–160. DOI 10.1006/jcta.1997.2780.
N. Alon, D. N. Kozlov, and V. H. Vũ (1996). The geometry of coin-weighing prob-
lems. In Proc. 37th Conf. Foundations of Computer Science, pp. 524–532. DOI
10.1109/SFCS.1996.548511.
J. C. Baillif (1982). Superpuzzles. Prentice-Hall.
B. Descartes (1950). The twelve coin problem. Eureka 13(7): 20.
F. J. Dyson (1946). Note 1931—the problem of the pennies. The Mathematical
Gazette, 30(291): 231–234.
D. Eves (1946). Problem e712–the extended coin problem. American Mathemat-
ical Monthly 53: 156.
N. J. Fine (1946). Problem 4203—the generalized coin problem. 53: 278; Solution,
54(1947) 489–491.
R. L. Goodstein (1945). 1845. Find the penny. The Mathematical Gazette, 29(287):
227. DOI 10.2307/3609266.
H. D. Grossman (1945). The twelve-coin problem. Scripta Mathematics 11: 360–
361.
R. K. Guy and R. J. Nowakowski (1995). Coin-weighing problems. The American
Mathematical Monthly, 102(2): 164. DOI 10.2307/2975353.
X. Hu, P. Chen, and F. Hwang (1994). A new competitive algorithm for the
counterfeit coin problem. Information Processing Letters, 51(4): 213–218. DOI
10.1016/0020-0190(94)90122-8.
T. Khovanova (2013a). Weighing coins during the Mystery Hunt. http://blog.
tanyakhovanova.com/?p=448.
154 Chapter 14. Coins of Three Different Weights

T. Khovanova (2013b). Parallel weighings. http://arxiv.org/pdf/1310.


7268v1:PDF.
K. Knop (2013). Weighings on two scales. The Ethereal Template (in Russian).
D. N. Kozlov and V. H. Vu (1997). Coins and cones. Journal of Combinatorial
Theory, Series A, 78 (1): 1–14.
J. G. Mauldon (1978). Strong solutions for the counterfeit coin problem, IBM Re-
search Report RC 7476 (#31437).
E. Purdy (2011). Lower bounds for coin-weighing problems. ACM Transactions
on Computation Theory, 2 (2): 1–12. DOI 10.1145/1944857.1944858.
L. Pyber (1986). How to find many counterfeit coins? Graphs and Combinatorics,
2(1): 173–177. DOI 10.1007/bf01788090.
E. D. Schell (1945). Problem e651—weighed and found wanting. American Math-
ematical Monthly, 52: 42.
N. J. A. Sloane (2010). The Online Encyclopedia of Integer Sequences. http:
//oeis.org.
M. R. Spiegel (1998). Mathematical handbook of formulas and tables. McGraw-
Hill, New York. DOI 10.2307/2004985.
Wikipedia (2016). Tournament sort. Wikipedia, the free encyclopedia. https://
en.wikipedia.org/wiki/Tournament_sort?oldid=740405271. [Online;
accessed 2014].
L. Withington (1945). Another solution of the 12-coin problem. Scripta Math.,
11: 361–363.
15
Rubber Bandzzles:
Three Mathematical
Puzzle-Art Challenges
George Hart

It is possible to ignore many boring office meetings if you can distract yourself
with handy office supplies. Should there be rubber bands lying about on the
conference table of your next dreary meeting, here are three artistic challenges
for entertaining yourself: The Worm, Infinity Squared, and Pentadigitation.

15.1 The Worm


The Worm is a miniature sculpture and a study in conservation of twist. I’ve
enjoyed replicating it hundreds of times over the years. As Figure 15.1 indicates,
The Worm is a single rubber band very tightly wound. It is twisted as in a rubber-
band powered propeller airplane ready to go, but it is completely stable. It does
not untwist even if picked up and stretched. Can you discover how to make one
before reading my solution below?

15.2 Infinity Squared


Infinity Squared is a kinetic sculpture that you make with one rubber band and
the thumb and two fingers of each hand. To warm up to it, first make the very
155
156 Chapter 15. Rubber Bandzzles

Figure 15.1. The Worm

simple motion I call Zero, shown in Figure 15.2(a), which is basically twiddling
your thumbs with a rubber band not slipping around them. Then make Infinity,
which uses the thumb and forefinger of each hand inside a rubber band that
has been twisted into a figure-eight shape (Figure 15.2(b)). Since the crossed
loop naturally sits horizontally and you can do the motion forever, I think of it
as ∞. In a sense, your thumbs together make one pulley and your index fingers
make another, and the rubber band is a crossed conveyor belt. You drive it by
bringing the thumb and forefinger of one hand together through the other pair,
then switching which hand is on the inside. (Try it in reverse as well.) After
mastering Infinity, you will be ready for the Infinity Squared challenge, which is
like Infinity, but with three loops and two crossings. You alternate between the
positions shown in Figures 15.2(c) and 15.2(d). The six-finger motion that keeps
it going smoothly is addictive once you master it. (Be sure to try it in the reverse
direction as well.)

Figure 15.2. (a) is Zero, (b) is Infinity, and (c) and


(d) are two positions in the cyclic motion of Infinity
Squared.

15.3 Pentadigitation
The goal of Pentadigitation, which is this mathematical performance art, is to
amaze or amuse your friends and coworkers by making a pentagram around the
George Hart 157

Figure 15.3. Rubber band pentagram

five fingers of one hand, using just the fingers of that hand. Start with a rubber
band loose in the palm, and with just that hand, manipulate it to match Figure
15.3. Once you learn to make one, it is surprisingly easy (via neuronal symme-
try?) to do one star simultaneously in each hand.

15.4 Solutions
(1) The Worm. The secret is that one half is twisted clockwise and the other
half is twisted counterclockwise, with a tight little knot at the juncture to
prevent the halves from canceling. To make it, repeatedly roll the rubber
band along the thumbs and forefingers, continuing as many times as possible,
and ending up as in Figure 15.4(a). One side is wound tightly clockwise, the
other is wound tightly counterclockwise, and finger pressure keeps it from
unwinding. Then bring the ends together in one hand and hold the center as
in Figure 15.4(b) to keep it from unwinding. The other hand is now available
to make a simple overhand knot at the center. Tighten the knot to be as small
as possible and then temporarily untwist, stretch, and redistribute the turns
in each half to be straight, neat, and even as in Figure 15.1.
(2) Infinity Squared. I know of no secret to this other than practice. The fingers
will smoothly alternate between the two positions shown in Figures 15.2(c)
and 15.2(d) as the rubber band moves along without slipping. I’ve been do-
ing this since I was a kid, so it seems like a natural motion to me, but your
“mileage” may vary. (After you master it, for extra credit try Infinity Cubed
and so on, until you run out of fingers.)
(3) Pentadigitation. This can be solved several ways, depending on how flexi-
ble your thumb and fingers are. I like to first get the rubber band on fingers
4 and 5 (ring finger and pinkie) as in Figure 15.5(a). Dip the thumb into
the loop and pull the far side across the palm to get to the position of Figure
158 Chapter 15. Rubber Bandzzles

Figure 15.4. Steps in making The Worm.

Figure 15.5. Steps in making Pentadigitation.

15.5(b). Dip finger 3 into the thumb-loop, pull up the side furthest from that
finger, then drop the loop from the thumb, to get to the position of Figure
15.5(c). Lift the near part of the finger-5 loop with the thumb, and then let
finger 2 grab it from below, and release the thumb to get to the position of
Figure 15.5(d). Finally, the thumb can lift the short center band marked X to
obtain the pentagram of Figure 15.3.

15.5 Conclusions
Mathematical rubber-band puzzle-sculpture, kinetic art, and performance art are
possible on a small scale. I would be pleased if copies of these little artworks are
soon enlivening boring conference rooms all around the world.
George Hart 159

Further Reading
G. Hart (n.d.). Personal website. http://georgehart.com/ with links to
YouTube videos.
Part 5

Art, Sculpture, and Design


There are different notions of beauty in mathematics. While a particularly
elegant proof may be beautiful to those who can read it, mathematics can also
be used to create more accessible beauty—art that can be appreciated by any-
one. The two papers in this section describe the development and construction
of mathematical art at two distinct scales—one huge and static, and one small
and manipulable.
16
Comet!
George Hart

16.1 Abstract
Swooshing across the science center atrium at Albion College, my sculpture
Comet! is over 100 feet long from one end to the other. It consists of nine dif-
ferent orbs of powder-coated aluminum suspended by chain from the ceiling,
each between 42 and 48 inches in diameter. They can be understood as 3D slices
of a four-dimensional sculpture that is visibly polyhedral at the start and grad-
ually morphs into an intricate flower-like final form. Each stage has a darker
core structure intertwined with a lighter colored outer tangle. The initial orb is
colored with two shades of light yellow, successively deeper shades of orange are
used in the middle of the room, and rich reds appear at the far end. Viewing each
component in turn, the final orb can be understood in logical steps, like a math-
ematical derivation. On the construction day, after three years of planning, over
one hundred members of the Albion college community—students, faculty, and
others—worked with me to assemble it at a large public “sculpture barn-raising.”
The interdisciplinary mix of math, art, computer science, and engineering is a
combination that Martin Gardner would have certainly enjoyed.

16.2 Design and Preparation


Mathematical sculpture celebrates in part what it means to be human: in partic-
ular, our innate attraction to form, pattern, and structure. I enjoy creating such
artwork and involving others in the assembly process. Spread out over a period
163
164 Chapter 16. Comet!

Figure 16.1. Comet! Aluminum with steel connec-


tors; 100 ft.

of more than three years, I led a project to create a large mathematical sculpture
for the newly constructed Science Center atrium at Albion College, in Albion,
Michigan. The project culminated in a public assembly event on Saturday, Sep-
tember 13, 2008, where thousands of precut metal parts were assembled into a
series of colorful orbs and lifted into the air. The sculpture, called Comet!, is per-
manently suspended along a curved path in the atrium for all to enjoy. Figure
16.1 is a view from the end of the room closest to the ninth orb.
Comet! consists of nine orbs, each made of 90 laser-cut aluminum parts joined
with 120 laser-cut steel brackets and held together by 600 nuts, 600 washers, and
600 bolts. That makes a grand total of 18090 parts not including the suspension
chain and connection hardware. The laser-cut steel and aluminum parts were
first powder coated in ten different shades, being careful to keep track of differ-
ent shades for connector brackets with two different dihedral angles. Although
I designed the sculpture and supervised its construction, this was certainly not a
one-man job!
I was first contacted early in 2005 by Albion faculty with the idea that their
new Science Center would be enhanced by the commission of a mathematical
sculpture. After some discussion and planning, I visited the campus in October
George Hart 165

2006 to present a talk on mathematical sculpture and view the site. On seeing the
atrium space, I was attracted to the architectural design, which includes a floating
bridge with a floating staircase down to the ground level, plus a well-thought-out
four-story staircase with varied projections into the space. Large glass walls to
the outside and windows from surrounding offices allow viewing objects in the
space from additional points of view. My main concern was the large size. I didn’t
think I could make something sizable enough to fit properly in such a vast vol-
ume. In discussion with the core group of Albion faculty on the project—David
Reimann, Darren Mason, and Gary Wahl—we came up with the idea to have a
multipart sculpture that would span across the space. They wrote a proposal for
funding the project, emphasizing interdisciplinary connections between math-
ematics, computer science, and the arts, and pointing out the value of a public
sculpture barn raising to the academic and broader community.
The proposal was approved, additional funding was also found, and I began
detailed work on the design. The atrium roof is divided into nine bays by support
beams, and there were lights, dinosaurs, and projection equipment already sus-
pended from those beams that had to be worked around. From the architectural
plans, I selected approximate locations for the nine orbs to hang at the midlines
of the nine bays. They would each hang from a “V” of chains tied to two divid-
ing beams, so as to be clear of the existing obstacles. On my second trip to the
campus, we placed nine helium balloons in the space to get a sense of the nine
positions. We tied these to chairs so we could move them around and adjust the
height of the strings. We viewed them from all vantage points and measured their
positions. Figure 16.2 shows the balloons in place. From the balloon measure-
ments, we made plans for chains to be suspended down from the beams to the
appropriate height for each.
The path of orbs starts high at one end of the room, where it can be seen
through windows from the outside street, swoops dramatically down towards the
floor to engage the viewer, bends back and up to follow the curve of the internal
stairway, then makes a reverse hook over the floating bridge for a close-up fin-
ish. Along the way, the path stays clear of the suspended fossil dinosaurs and
tries not to block the light beam between a digital projector and its screen. By
walking around and through the space, the viewer has opportunities to observe
the sculpture from above, below, and all sides.
I had considered many ideas and made many sketches for the design of the
nine individual orbs. In the end I narrowed them down to two design proposals
which I brought to the faculty at Albion for feedback. In Plan A, the nine orbs
were identical in structure except that small curving appendages varied from one
to the next to give a sense of a swimming motion. This underlying uniformity of
166 Chapter 16. Comet!

Figure 16.2. Helium balloons used for positioning


Comet!

design would have simplified the logistics significantly. Plan B involved nine dif-
ferent structures, entailing a much more complex design, fabrication, and assem-
bly process, but would result in a much richer final result. I made a paper model
of the ninth orb from the Plan B design, shown in Figure 16.3, to help commu-
nicate the richness of its ideas. In the end, the Albion faculty opted for the more
complex Plan B, in part because math faculty liked the analogy between a for-
mal mathematical proof and a series of sculptural forms which start at a familiar
place and evolve stepwise to a novel ultimate result.
George Hart 167

Figure 16.3. Six-inch paper model of orb nine.

To deal with the assembly-day logistics of making nine distinct orbs simulta-
neously, we expanded the faculty committee by a dozen members. Each orb in-
volves a highly intricate and slightly different interweaving of component parts,
so there would be too much going on for me to supervise alone. We planned in-
stead to build one orb the evening before the main event, with a committee of
sixteen faculty members helping me. I would train them in the procedure and
coach them about foreseeable problems to be alert for. Then on the assembly
day, the remaining eight orbs could be assembled by the public in eight groups,
with two trained faculty serving as leaders at each table. Additional faculty were
enlisted, and this plan turned out to work well.
Figure 16.4 gives a summary of the nine shapes in glyph form. Each pat-
tern shown is repeated 30 times, rotated once into each of the 30 face planes of a
rhombic triacontahedron (Hart, 2007). Thus the overall form can be understood
as a subset of a stellation of the rhombic triacontahedron. This is not a familiar

Figure 16.4. Nine orbs’ component parts.


168 Chapter 16. Comet!

structure for people unfamiliar with polyhedral geometry, but if we draw the two
diagonals in each rhombic face of a rhombic triacontahedron, one sees that the
short diagonals form the edges of a dodecahedron and long diagonals form the
edges of its dual icosahedron. As these Platonic solids are well known, I chose a
design very close to this structure for orb one. To enrich it and provide landmarks,
the vertices of the dodecahedron are shown as open circles and the vertices of the
icosahedron are made in a pentagrammatic star form. From that starting point, a
series of gradual morphings, crossings, and piercings lead ultimately to the final
orb nine. The next step was to make detailed engineering designs and prepare
files to send to the laser cutter. This involves keeping track of thousands of little
details involving spline curves, bolt sizes, hole diameters and clearances, material
thickness, bending radii, dihedral angles, weight, tensile strength, etc., while not
losing sight of the overall artistic vision. To visualize the nine overall forms and
to verify that the components can be physically positioned without intersecting
each other, I used my own sculpture design software, described in (Hart, 2007).
Final drawings were prepared with general purpose drawing tools and sent to the
laser cutter. As a check, to make sure that all the parts actually mate together as
planned, we asked the laser cutter to prepare an initial ten parts of each shape to
use in a fit-test.
I flew out to Albion for a third visit in August 2008. We put together the test
parts and verified that no corrections were needed in the parts design. Figure
16.5 shows one of the test assemblies of the uncolored aluminum components.
At that visit, we also finalized the color choices for the powder coating company.
I wanted the orbs to gradually change in color from one end of the room to the
other. I also wanted each to be two colors: one color for the 60 outer components
and a slightly darker color for the 30 inner components. In addition there are 60
brackets connecting inner parts and another 60 connecting outer parts, and each
bracket must match its part in color. To minimize the number of colors required
and introduce another level of continuity, we chose to have the darker color of
each orb be the same as the lighter color of the next orb. With this design, a total
of only ten colors was needed: yellows, oranges, and reds. The remaining parts
were cut, all were powder coated, chains were suspended from the ceiling beams,
the sculpture barn raising was advertised, food was ordered, etc.
After careful planning and organized worry on my part about every possi-
ble thing that might go wrong, the assembly itself went off with no problems.
Nothing got lost; not too many parts got scratched; nothing fell and was bent;
no maniacs ran off with key components. One connection was a bit tight and it
helped to have some small hands present to get its bolts in place. Some scratches
occurred, but we had planned for this and had enough spares. Overall, every-
thing went smoothly.
George Hart 169

Figure 16.5. Test fit, with David Reimann

On the afternoon before the construction, I flew out to Albion for my fourth
time. On the way from the airport, we picked up the parts from the powder coater,
finished just in time. That evening, the sixteen group leaders and I assembled orb
number nine and suspended it above the atrium bridge. The parts went together
exactly as planned and we worked out a good way to lift orbs into position and
shackle them to the chains, which had already been installed. In preparation
for the next day’s construction, I explained to the group leaders how each of the
remaining orbs were in some ways the same and in other ways different from
the one we had built. At the barn raising, over one hundred members of the
Albion college community—students, faculty, and others—participated in the
construction over a period of several hours. We worked around eight tables, each
with two faculty build leaders and changing groups of volunteers who came and
went according to the free time in their schedules during the day. I ran back and
forth between all the tables checking on everything and debugging occasional
problems. Figure 16.6 shows a view of the day.
Each orb has 30 inner parts that each mate via angle connectors to four oth-
ers. The participants must be careful not to reverse parts or misconnect them.
The bolts must be tightened securely, so we checked there is no vibrational buzz
by tapping on everything. Then the 60 outer parts were connected. Each mates
to the center of one inner part and to two other outer parts. At this stage there is
170 Chapter 16. Comet!

Figure 16.6. Sculpture barn-raising activities

plenty of room for confusion and misconnected parts. Occasionally, I found com-
ponents that had to be unbolted and replaced in the correct orientation. Getting
every single bolt tight was something of a challenge because if we tapped and
heard a rattle it was not always easy to locate the source of the sound. Eventually
everything was ready to hang. Three of the bolts in each orb were replaced with
eyebolts for the chain to connect to. These points were chosen symmetrically so
each orb hangs with a three-fold axis vertical. We took a documentary photo of
each (see Figure 16.7 for an example), and then the building’s staff were able to
raise them into position with no difficulties.
At the end of the day, it was deeply satisfying for this artist to see the fruits
of so much labor hanging ripe for all to savor.

16.3 Conclusion
A collaborative artwork such as Comet! is an iconic way to illustrate the ties
that connect art, math, computer science, and engineering. Academics some-
times need to be very narrow and compartmentalized when working deeply in
George Hart 171

Figure 16.7. One of the orbs in Comet! (Photo cour-


tesy of Gary Wahl.)

their own specialties, so it is useful to also create a social event and a permanent
sculptural reminder of the broader inter-relatedness of our fields. A sculpture
barn raising event creates a community while creating a tangible focal point that
manifests the common bonds between disciplines. In the process, many students
are exposed to a new perspective on mathematics and computer science, which
may have a subtle long-range impact on their career decisions. Informal feed-
back from students, faculty, and community members indicates that the Comet!
project was a great experience for all participants. For more information there are
many additional images documenting details of the design, preparations, and the
construction event available online at (Hart, n.d.). In addition, there is an enter-
taining time-lapse video of the entire construction and hanging process.

Acknowledgments
This was a community art project, and I am happy to thank many people who
contributed in many ways, especially all the students and others who attended
and participated in the assembly event. Prof David Reimann, chair of the Albion
Mathematics and Computer Science department championed this project, found
172 Chapter 16. Comet!

funding, and took care of many aspects of the organization. Professors Darren
Mason (Math/CS) and Gary Wahl (Art & Art History) provided a great deal of
additional support throughout all its stages. The additional group leaders who
participated by attending the previous night’s practice preparation and then lead-
ing the construction all day at one table are: David Anderson (Math/CS), Amy
Bethune (Chemistry), Mark Bollman (Math/CS), Lynne Chytilo (Art & Art His-
tory), Michael Dixon (Art & Art History), Andrew French (Chemistry), Vanessa
McCaffrey (Chemistry), Karla McCavit (Math/CS), Carrie Menold (Geology),
Robert Messer (Math/CS), Aaron Miller (Physics), Daniel Mittag (Philosophy),
and Martha O’Kennon (Math/CS). The local company Caster Concepts provided
the laser cutting and Finishing Touch did the powder coating. Figure 16.7 photo
is courtesy of Gary Wahl; the others are by the author. Portions of this material
were presented at the ISAMA 2009 conference in Albany, NY—the International
Society of the Arts, Mathematics, and Architecture.

Further Reading
G. W. Hart (n.d.). http://www.georgehart.com.
G. W. Hart (2007). Symmetric sculpture. Journal of Mathematics and the Arts,
1(1): 21–28. DOI 10.1080/17513470701228040.
17
Developing Topsy Turvy
and Number Planet
M. Oskar van Deventer
Igor Kriz

17.1 Summary
This article is about a mathematics collaboration in the spirit of Martin Gardner.
Igor Kriz illustrated group theory and the sporadic simple Mathieu group 𝑀12
(Wikipedia, 2015) in Scientific American (Kriz and Siegel, 2008) by turning them
into permutation puzzles. He challenged readers to find a mechanical imple-
mentation of his 𝑀12 puzzle.
Oskar van Deventer took up the challenge. The resulting two completely
different implementations, Topsy Turvy and Number Planet, are described in this
article.1

17.2 Challenge in Scientific American


The July 2008 issue of Scientific American featured an article by Igor Kriz on
group theory (Kriz and Siegel, 2008). The purpose of the article was to educate
people on group theory. It explained simple groups, which are the group-theory
1 A more technical version of this article was published by the authors in Game and Puzzle Design

2(2016) 9–16.

173
174 Chapter 17. Developing Topsy Turvy and Number Planet

1 2 3 4 5 6 7 8 9 10 11 12
Invert = ( 12 11 10 9 8 7 6 5 4 3 2 1 )
Merge = ( 11 23 35 47 95 11
6 7 8 9 10 11 12
12 10 8 6 4 2 )

Figure 17.1. The 𝑀12 puzzle uses two permuta-


tions called Invert and Merge.

equivalent of prime numbers. It highlighted researchers’ multidecade mathe-


matical quest to identify and classify all simple groups. And it illustrated the
concept of a simple sporadic group with a set of electronic puzzles, programmed
by Igor’s graduate student Paul Siegel. One of the puzzles was the 𝑀12 puzzle,
based on the simple sporadic Mathieu 12 group.
The 𝑀12 puzzle is played as follows. Take twelve tokens, numbered 1 to 12.
There are two permutations: Invert and Merge (see Figure 17.1). The object of
the 𝑀12 puzzle is similar to that of the Rubik’s Cube: to unscramble it by using
only the two permutations.
Igor suggested in the article that the puzzle might be mechanically imple-
mented, perhaps using a rotating device and a system of gears. He left it as a
challenge to the reader.

17.3 Implementation #1: Topsy Turvy


Oskar van Deventer took up the challenge to implement the puzzle using a set of
tokens numbered 1 through 12. The Invert operation is easily implemented, as
one can just turn around the set of tokens using some sort of mechanical device.
The Merge operation is more challenging. Oskar’s first idea was to implement the
Merge using some slapstick construction, but he could not find a good mecha-
nism. However, the reverse operation to Merge, which he christened Split, might
be easier to implement. Oskar contacted Igor, who confirmed that Split could be
used.
Oskar had previously developed several puzzle mechanisms to manipulate
dropping tokens called Jukebox and Pachinko (see Figure 17.2). The former uses
physical switches to alternate moving tokens left and right. The latter uses a pat-
tern of grooves that holds one or two tokens until one more token is inserted that
pushes the other tokens down. Oskar found that the latter mechanism could be
used to build the 12-splitters needed for the Split operation.
Figure 17.3 shows a working prototype of Topsy Turvy, which implements
the 12-splitter. A big crank is used to move the 12 tokens into the 12-splitter. The
Invert operation is implicitly implemented, as the crank can be turned either to
the left or right. When turned, the 12 tokens are dropped in one by one. The
first 11 tokens will then land stably on top of one another. However, when the
M. Oskar van Deventer and Igor Kriz 175

Figure 17.2. The Jukebox and Pachinko puzzle


mechanisms designed by Van Deventer

Figure 17.3. Topsy Turvy, featuring a 12-splitter

final 12th token drops, it rolls down over the 11th, and while dropping, it pushes
the 11th out of position. Then the 11th pushes the 10th out of position, which
pushes the 9th, which pushes the 8th, an so on. In this cascade, the whole stack
of tokens falls apart, with the even tokens moving to the right and the odd ones
to the left.
Oskar had to build several prototypes to get the mechanism right. The proto-
types were built using the laser cutter of Peter Knoppers, using MDF and acrylic.
The tokens are made of cast tin, using laser-cut MDF moulds. In order to have
the mechanism turn smoothly, four large gears act as a ball bearing, carrying the
weight of the crank mechanism. A rattle mechanism is used to force a user to
finish a move once started, preventing illegal moves.
The first prototype had the major flaw that a user could continue turning
while the tokens were still dropping. Allowing that to happen causes tokens to
collide when they are caught by the crank mechanism at the bottom, enabling
both illegal moves and blockage of the intended mechanism. George Miller found
an elegant solution to this problem: a toggle switch which limits the rotation of
176 Chapter 17. Developing Topsy Turvy and Number Planet

Figure 17.4. The gears, rattle mechanism, and tog-


gle switch used to prevent illegal moves in Topsy
Turvy.

the crank between −240 and +240 degrees (Figure 17.4. With the switch in place,
a user has to turn the crank all the way back, which takes sufficient time for the
tokens to settle at the bottom. Magnets were used to make the switch bistable.
Another problem was that tokens could skip the entry if the crank is turned
too fast. Peter Knopper’s solution was to place a pin at the top entry of the grooves,
which forces the tokens down.
With all major problems solved, the third prototype was found to work in a
satisfactory way.

17.4 Implementation #2: Number Planet


While Oskar was working on Topsy Turvy, Igor suggested a completely differ-
ent implementation. Igor had found special planar permutations that also im-
plement the 𝑀12 group. The two permutations are called Rotate and Swap; see
Figure 17.5.
Oskar started 3D sketching. After a lot of communication with Igor, a mech-
anism was found that could do the trick; see Figure 17.6.
However, Oskar was not satisfied with the mechanism and its round tokens.
A much better mechanism might be possible if the 0 and 1 were not surrounded
by the 11-2 swap. Oskar asked Igor whether there might not exist a better planar
𝑀12 permutation. Igor started looking using a Maple program, while Oskar used
a Python program written by George Miller. With crossing emails, Igor beat Os-
kar by only five minutes, both discovering that the requested planar permutation
does indeed exist.
Using this permutation, Oskar made a 3D design that used trapezoid-shaped
tokens that push each other better when performing the Rotate operation; see
Figure 17.7.
M. Oskar van Deventer and Igor Kriz 177

Figure 17.5. The Rotate and Swap permutations

Figure 17.6. Mechanism implementing Rotate and


Swap

Figure 17.7. A better planar permutation enabling


trapezoid-shaped tokens
178 Chapter 17. Developing Topsy Turvy and Number Planet

Figure 17.8. The Number Planet design, and FDM


and SLS prototypes

The resulting puzzle, called Number Planet by Igor, was prototyped using 3D
printing technologies. The first prototype, made by UM3D in ABS-based fusion
deposition modeling, was a failure because Oskar had made a modeling error. A
second prototype worked reasonably well, but it was still cumbersome to assem-
ble with its many subassemblies.
A third prototype made by TNO Netherlands using nylon-based selective
laser sintering and painted with textile acid dye, was finally a success; see Fig-
ure 17.8.

17.5 Solving the 𝑀12 puzzles


With working prototypes available, the reader may wonder how these puzzles
should be solved. First of all, it should be noted that both implementations fea-
ture two permutations, albeit different ones.
For Topsy Turvy:
Left: 1-2-3-4-5-6-7-8-9-10-11-12 → 11-9-7-5-3-1-2-4-6-8-10-12.
Right: 1-2-3-4-5-6-7-8-9-10-11-12 → 2-4-6-8-10-12-11-9-7-5-3-1.
For Number Planet:
Rotate: 0-1-2-3-4-5-6-7-8-9-10-11 → 0-2-3-4-5-6-7-8-9-10-11-1.
Swap: 0-1-2-3-4-5-6-7-8-9-10-11 → 0-1-9-4-3-6-5-8-7-2-11-10.
Secondly, both mechanisms implement the 𝑀12 group, which has
12 × 11 × 10 × 9 × 8 = 95040
permutations. The 𝑀12 group has the property that if five tokens are at their cor-
rect place, then the other seven tokens are correct too (Wikipedia, 2015). Using
this information, one could envision the following solution approaches.
• God’s Table by computer: As the solution space is very small, it is quite fea-
sible to build a “God’s Table” enumerating all possible states and the solution
sequence for each state. This is exactly what George Miller did. The file that
M. Oskar van Deventer and Igor Kriz 179

his Python program produced is small enough to be used on a smartphone,


so you can always have a solution at hand. Although God’s Table provides
the fastest solution, it is impossible for a human being to memorize.
• Recursive solution by hand: A solution worked out by Igor uses a small set
of recursive operations. While much easier to memorize, the recursiveness of
the solution requires many (thousands of?) moves. This makes the solution
rather impractical for the mechanical versions.
• Computer-aided optimization: A computer could be used to find the short-
est five sets of operations that brings five tokens into their correct places one
by one, using the property of 𝑀12 mentioned above.

17.6 Mission accomplished: Now what?


This article presented two completely different implementations for Igor Kriz’s
𝑀12 puzzle challenge. Topsy Turvy uses gravity and its operations are nonrevers-
ible. Number Planet is a twisty puzzle and every operation can be undone. Topsy
Turvy occasionally cascades too early if it is handled too wildly. The prototypes
are not perfect. The rough surfaces of the 3D-printed Number Planet prototypes
are sometimes a bit sticky.
Both puzzles are excellent illustrations of 𝑀12 simple sporadic group. They
would make interesting collector’s items for connoisseurs. At the moment of
writing this article, it is unclear whether the puzzles have any further commercial
potential.

Further Reading
I. Kriz and P. Siegel (2008). Simple groups at play. Scientific American, 299(1):
84–89. DOI 10.1038/scientificamerican0708-84.
Wikipedia (2015). Mathieu group 𝑀12. Wikipedia, the free encyclopedia. https:
//en.wikipedia.org/wiki/Mathieu_group_M12?oldid=697630590. [On-
line; accessed 25-September-2016].
Part 6

Magic and Miscellany


Recreational math is much more than just games and puzzles. We conclude
our volume with two very different papers. The first analyzes a magic trick based
on flipping coins. The second presents a trio of puzzle typographic fonts, where
each letter or phrase is a miniature puzzle.
18
Coin-Flipping Magic
Nadia Benbernou
Erik D. Demaine
Martin L. Demaine
Benjamin Rossman

Prepared in honor of Martin Gardner for Gathering 4 Gardner 8

18.1 Summary
This paper analyzes a variety of generalizations of a coin-flipping magic trick in-
vented independently by Martin Gardner and Karl Fulves. In the original trick,
a blindfolded magician asks the spectator to flip three coins, forcing them into
an all-equal state with surprisingly few moves. We generalize to any number of
coins, dice with more than two sides, and multiple flips at once. Next we con-
sider a generalization described by Martin Gardner in which the spectator can
rearrange the coins in certain ways in between each flip. Finally, we consider the
variation in which the magician equalizes the number of heads and tails, which
can be achieved exponentially faster.

18.2 Introduction
The trick. Thank you, dear reader, for volunteering for a magic trick! May I
ask, do you have a few coins that we could use for the trick? If not, you can
183
184 Chapter 18. Coin-Flipping Magic

Figure 18.1. Three pennies

borrow mine from Figure 18.1. Please get out three coins; they can be different
denominations. Now please arrange the coins in a line from left to right. Very
good. Now I will blindfold myself and look away. I guarantee that I cannot see
the coins.
To get started, I would like you to flip over some of the coins. You can flip
over as many or as few as you like. The only rule is that the coins should not be
all heads or all tails. Let me know when you are finished. Good, let us proceed.
I am now visualizing your coins in my mind. With you acting as my hand, I
will make the coins all the same: all heads or all tails.
Please flip over the left coin. Are the coins now all the same? One third of
my readers will shout “yes!” and be blown away by my omniscience. For the rest
of you, the trick continues.
Please flip over the middle coin. Very good. Now are the coins the same?
Another third of my readers will be surprised by my fast success. For the rest of
you, the trick continues.
Let me see; I must have made a mistake in visualizing your coins. Ah yes, I
see. I shouldn’t have flipped the left coin in the first place. Please flip over the
left coin, back to the way it was. Now, I tell you, the coins are all the same. Feel
free to check my blindfolds.

18.3 Background
This self-working magic trick appears in Karl Fulves’s book The Children’s Magic
Kit (Fulves, 1980, p. 15). According to that book, the trick was independently
devised by Martin Gardner and Fulves, based on an idea of Sam Schwartz. It
works with coins or cards, over the telephone or the radio.
At first we, and presumably many spectators, find it surprising that just three
blindfolded flips are enough to equalize the three coins. Indeed, there are 2 × 2 ×
2 = 8 possible states of the coins (HHH, HHT, HTH, THH, HTT, THT, TTH, TTT).
How do we navigate to two of these states (HHH or TTT) using just three moves
Nadia Benbernou et al. 185

(and often fewer)? Motivated by this simple question, this paper studies several
generalizations and variations of this magic trick.

18.4 Results
We begin with a simple generalization of the trick to 𝑛 coins. This generaliza-
tion, and the original trick, turn out to be easy to analyze: they are equivalent to
Hamiltonian paths in an (𝑛 − 1)-dimensional hypercube graph, and the classic
Gray code gives one such solution. (The Gray code is an ordering of 2𝑛 𝑛-bit bi-
nary numbers such that only a single bit changes at once; it can be generated by
starting with 0, and then always changing the least significant bit that results in
a number not yet seen.) Not surprisingly, the number of moves required grows
exponentially with 𝑛. More interesting is that we save an entire factor of two by
having two goal states, all heads and all tails. Namely, the worst-case optimal
number of blindfolded flips is 2𝑛−1 − 1. The analysis also easily generalizes to
𝑘-sided dice instead of coins: later, we show that the worst-case optimal number
of blindfolded operations is 𝑘𝑛−1 − 1.
This family of tricks is thus really most impressive for 𝑛 = 3 coins, where the
number 3 of flips is really quite small; beyond 𝑛 = 3 or 𝑘 = 2, the number of flips
grows quickly beyond feasibility. For sake of illustration, however, Figure 18.2
shows a magic-trick sequence for four coins.
One solution to this exponential growth is to change the goal from the two
all-heads and all-tails states to some larger collection of states. In Section 18.7, we
consider a natural such goal: equalize the number of heads and tails. This goal
is exponentially easier to achieve. Within just 𝑛 − 1 coin flips, the magician can
force the numbers of heads and tails to be equal. The algorithm is simple: just
flip one coin at a time, in any order, until the goal has been reached. Figure 18.3
shows an example for 𝑛 = 6. Although not obvious, this algorithm will succeed
before every coin has been flipped once. Furthermore, by randomly flipping all

Figure 18.2. Equalizing four coins with at most


seven flips
186 Chapter 18. Coin-Flipping Magic

Figure 18.3. Equalizing the numbers of heads and


tails in six coins using at most four flips

the coins in each move, the magician expects to require only around √𝑛 moves.
The practicality of this type of trick clearly scales to much larger 𝑛.
Returning to the goal of equalizing all the coins, the next generalization we
consider is to allow the magician to flip more than one coin at once, between
asking for whether the coins are yet all the same. This flexibility cannot help the
magician to equalize the coins any faster than 2𝑛−1 − 1 moves, but it can help
obscure what the magician is doing. For example, if the magician had to repeat
the three-coin trick several times, it might help to try some of the variations in
Figure 18.4. Under what conditions can the magician still equalize 𝑛 coins, ide-
ally in the same number 2𝑛−1 − 1 of moves? Obviously, flipping 𝑛 − 1 of the coins
is equivalent to flipping just one coin. On the negative side, in Section 18.8, we
show that the sequence of flips cannot vary arbitrarily: if the spectator is allowed
to choose how many coins the magician should flip in each move, then the ma-
gician can succeed only if 𝑛 ≤ 4 (no matter how many moves are permitted).
On the positive side, in Section 18.9, we show that it is possible to flip most fixed
numbers of coins in every move and achieve the optimal worst case of 2𝑛−1 − 1

Figure 18.4. Alternate solutions to equalizing


three coins with at most three moves, flipping more
than one coin in some moves
Nadia Benbernou et al. 187

Figure 18.5. Equalizing four coins that the spec-


tator can rotate at each stage, using at most seven
moves

moves. This result is fairly technical but interesting in the way that it generalizes
Gray codes.
The final variation we consider allows the spectator to rearrange the coins
in certain ways after each move. Again this can only make the magician’s job
harder. In each move, the magician specifies a subset of coins to flip, but before
the spectator actually flips them, the spectator can rearrange the coins according
to certain permutations. Then, after flipping these coins, the spectator reveals
whether all coins are the same, and if not, the trick continues. In Section 18.10,
we characterize the exact group structures of allowed rearrangements that still
permit the magician to equalize the coins. For example, if 2𝑘 coins are arranged
on a table, then the spectator can rotate and/or flip the table in each move, and
still the magician can perform the trick. Figure 18.5 shows the solution for four
coins arranged in a square that the spectator can rotate by 0, 90∘ , 180∘ , or 270∘
during each move.
The four-coin magic trick of Figure 18.5 goes back to a March 1979 letter from
Miner S. Keeler to Martin Gardner (Gardner, 1992), and was disseminated more
recently by Eric Roode (Roode, 2002). Keeler’s letter was inspired by an article of
(Gardner, 1992) about a somewhat weaker magic trick where, after the spectator
turns the table arbitrarily, the magician can feel two coins before deciding which
to flip. This weaker trick has been generalized to 𝑛 coins on a rotating circular
table and 𝑘 hands: the trick can be performed if and only if 𝑘 ≥ (1 − 1/𝑝)𝑛, where
𝑝 is the largest prime divisor of 𝑛 (Lewis and Willard, 1980; Laaser and Ramshaw,
1981) The fully blind trick we consider, without the ability to feel coins, was first
generalized beyond Keeler’s four-coin trick to 𝑛 dice, each with 𝑘 sides, on a rotat-
ing circular table: the trick can be performed if and only if 𝑘 and 𝑛 are powers of a
common prime (Yehuda et al., 1993). Interestingly, this characterization remains
the same even if the magician can see the dice at all times (but the spectator can
188 Chapter 18. Coin-Flipping Magic

still turn the table before actually flipping coins); however, the worst-case num-
ber of moves reduces from 𝑘𝑛 − 1 to 𝑛 + (𝛼 − 1)(𝑛 − 𝑝𝛽−1 ) where 𝑘 = 𝑝𝛼 and
𝑛 = 𝑝𝛽 . (Interestingly, the optimal number of moves for a specific sequence of
coins gives rise to the notion of “word depth”, now studied in the context of linear
codes in information theory (Etzion, 1997; Luo et al., 2000).)
Our general scenario considers an arbitrary “group” of permutations, in-
stead of just a rotating circular table. This scenario was also essentially solved
by (Ehrenborg and Skinner, 1995): they characterize performability in terms of
the chain structure of the group. Our characterization is simpler: the group must
have a number of elements equal to an exact power of 2. Our proof is also simpler,
showing a connection to invariant flags from group representation theory. It also
uses the most sophisticated mathematical tools among proofs in this paper.

18.5 𝑛 Coins

Figure 18.6. The graph corresponding to the three-


coin trick: the 3-dimensional binary cube

The simplest generalization is to consider 𝑛 coins instead of three. The goal


is to make the coins all the same (all heads or all tails) by a sequence of single
coin flips, where after each flip the magician asks, “Are the coins all the same
yet?”
We can visualize this problem as navigating a graph, where each vertex cor-
responds to a possible state of all the coins, and an edge corresponds to flipping
a single coin. This graph is the well-known 𝑛-dimensional binary hypercube; Fig-
ure 18.6 shows the case 𝑛 = 3. In general, the 𝑛-dimensional binary hypercube
has 2𝑛 vertices, one for each possible binary string of length 𝑛 (where 0 bits cor-
respond to heads and 1 bit corresponds to tails), and it has an edge between two
vertices whose binary strings differ in exactly one bit.
In the magic trick, the spectator chooses an arbitrary start vertex, and the
magician’s goal is to reach one of two goal vertices: 00 ⋯ 0 (all heads) or 11 ⋯ 1
(all tails). At each step, the magician can pick which edge to move along: flipping
Nadia Benbernou et al. 189

the 𝑖th coin corresponds to flipping the 𝑖th bit. The only feedback is when the
magician hits one of the goal vertices.
An equivalent but more useful viewpoint is to map coin configurations onto
the binary hypercube by defining a bit in a binary string to be 0 if that coin is the
same orientation (heads/tails) as the spectator’s original choice, and 1 if the coin
is different from the spectator’s original choice. In this view, the magician always
starts at the same vertex 00 ⋯ 0. The two goal configurations 𝑔 and 𝑔 are now the
unknown part; the only knowledge is that they are inversions of each other (with
0’s turned into 1’s and vice versa).
In order for the magician to be sure of visiting one of the two solution states,
the chosen path (sequence of coin flips) must visit either 𝑣 or its inversion 𝑣 for
every vertex 𝑣 in the hypercube. There are 2𝑛 total vertices, so the path must visit
2𝑛 /2 = 2𝑛−1 different vertices. This argument proves a worst-case lower bound
of 2𝑛−1 − 1 flips in the worst-case execution of the magic trick.
To see that 2𝑛−1 − 1 flips also suffice in the worst case, it suffices to find a
Hamiltonian path in any (𝑛−1)-dimensional subcube of the 𝑛-dimensional cube,
dropping whichever dimension we prefer. (A Hamiltonian path visits each vertex
exactly once.) The spectator sets this dimension arbitrarily to heads or tails, and
the Hamiltonian path explores all possible values for the remaining 𝑛 − 1 bits, so
eventually we will reach the configuration in which all bits match the dropped
bit. The subcube has 2𝑛−1 total vertices, so the presumed Hamiltonian path has
exactly 2𝑛−1 − 1 edges as desired.
The final piece of the puzzle is that 𝑛-dimensional cubes actually have Hamil-
tonian paths. This fact is well-known. One such path is given by the binary Gray
code, also known as the reflected binary code (Gray, 1953). This code/path can
be constructed recursively as follows. The 𝑛-bit Gray code first visits all strings
starting with 0 in the order given by the (𝑛 − 1)-bit Gray code among the remain-
ing bits; then it visits all strings starting with 1 in the reverse of the order given
by the (𝑛 − 1)-bit Gray code among the remaining bits. For example, the 1-bit
Gray code is just 0, 1; the 2-bit Gray code is 00, 01, 11, 10; and the 3-bit Gray code
is 000, 001, 011, 010, 110, 111, 101, 100. Figure 18.6 illustrates this last path.

Theorem 18.1. The optimal sequence of flips guaranteed to eventually make 𝑛


coins all heads or all tails uses exactly 2𝑛−1 − 1 flips in the worst case.

18.6 𝑛 Dice
One natural extension of flipping coins is to rolling 𝑘-sided dice. Suppose we have
𝑛 dice, each die has 𝑘 faces, and each face is labeled uniquely with an integer 0,
1, . . . , 𝑘 − 1. The spectator arranges each die with a particular face up. As before,
the magician is blindfolded. In a single move, the magician can increment or
decrement any single die by ±1 (wrapping around from 𝑘 to 0). At the end of
190 Chapter 18. Coin-Flipping Magic

such a move, the magician asks whether all the dice display the same value face
up. The magician’s goal is to reach such a configuration.
As we show in this section, our analysis extends fairly easily to show that
the magician can succeed in 𝑘𝑛−1 − 1 steps. A configuration of 𝑛 dice becomes a
𝑘-ary string of 𝑛 digits between 0 and 𝑘 − 1. In the most useful viewpoint, a digit
of 0 represents the same as the original state chosen by the spectator, and a digit
of 𝑖 represents that the die value is 𝑖 larger (modulo 𝑘) than the original die value.
Thus (0, 0, . . . , 0) represents the initial configuration chosen by the spectator, and
the 𝑘 goal states 𝑔0 , 𝑔1 , . . . , 𝑔𝑘−1 have the property that 𝑔𝑖 corresponds to adding
𝑖 to each entry of 𝑔0 (modulo 𝑘).
The analogous graph here is the 𝑘-ary 𝑛-dimensional torus. Figure 18.7 shows
the case 𝑛 = 𝑘 = 3. In general, the vertices correspond to 𝑘-ary strings of length 𝑛,
and edges connect two vertices 𝑎 = (𝑎1 , 𝑎2 , . . . , 𝑎𝑛 ) and 𝑏 = (𝑏1 , 𝑏2 , . . . , 𝑏𝑛 ) that
differ by exactly ±1 (modulo 𝑘) in exactly one position:
𝑏 = (𝑎1 , 𝑎2 , . . . , 𝑎𝑖−1 , 𝑎𝑖 ± 1, 𝑎𝑖+1 , . . . , 𝑎𝑛 ).

Figure 18.7. 3-ary 3-dimensional torus

Again we drop an arbitrary digit/dimension, and focus on the resulting 𝑘-ary


(𝑛 − 1)-dimensional subtorus. The magic trick becomes equivalent to finding a
Hamiltonian path in this subtorus. Such a path exists by a natural generalization
of the Gray code (Guan, 1998). Visiting all configurations of the other dice will
eventually match the value of the dropped dimension.

Theorem 18.2. The optimal sequence of die increments/decrements guaranteed to


eventually make 𝑛 𝑘-sided dice all the same uses exactly 𝑘𝑛−1 − 1 moves in the worst
case.
Nadia Benbernou et al. 191

18.7 Equal Numbers of Heads and Tails


In this section, we explore the variation of the magic trick in which the goal is
to equalize the numbers of heads and tails, instead of equalizing the coins them-
selves. We consider two strategies: a fast randomized strategy, and a simple de-
terministic strategy that achieves a balanced configuration in linear time.
Call a configuration balanced if it has an equal number of heads and tails.
Throughout, we assume 𝑛 is even, although we could adapt these results to the
case of 𝑛 odd by expanding the definition of balanced configuration to allow the
numbers of heads and tails to differ by at most 1.

18.7.1 Randomized Strategy. In the randomized strategy, in each move,


the magician flips each coin with probability 1/2. Thus the magician flips around
half the coins in each move, effectively randomizing the entire configuration.
We show that the magician reaches a balanced configuration in around √𝑛 such
moves:

Theorem 18.3. Using the randomized strategy, the magician balances 𝑛 coins
within 𝑂(√𝑛) steps with constant probability, and within 𝑂(√𝑛 lg 𝑛) steps with
probability 1 − 𝑂(1/𝑛𝑐 ) for any desired 𝑐 > 0.

Proof. For any two configurations 𝑎 and 𝑏 on 𝑛 coins, a single move from 𝑎
reaches 𝑏 with probability 1/2𝑛 . Hence, each move uniformly samples the config-
uration space. The number of balanced configurations is ( 𝑛/2 𝑛 ), so the probability

of reaching a balanced configuration in each step is ( 𝑛/2 )/2𝑛 . We simply need to


𝑛

determine the number of such trials before one succeeds.


First we lower-bound the probability of success using Stirling’s formula:
√2𝜋𝑛 (𝑛/𝑒)𝑛 𝑒1/(12𝑛+1) < 𝑛! < √2𝜋𝑛 (𝑛/𝑒)𝑛 𝑒1/(12𝑛) .
Thus
𝑛 𝑛
𝑛 𝑛! √2𝜋𝑛 ( ) 𝑒1/(12𝑛+1) 9𝑛+1
𝑒 2 𝑛
( )= ≥ 2
= √ 𝜋𝑛 ⋅ 2 ⋅ 𝑒 3𝑛(12𝑛+1) .
𝑛/2 (𝑛/2)! (𝑛/2)! 𝑛/2 𝑛/2
(√𝜋𝑛 ( ) 𝑒1/(6𝑛) )
𝑒
Hence,
𝑛
( )
𝑛/2
Pr{reaching balanced configuration in one move} =
2𝑛
9𝑛+1
2
≥√ ⋅ 𝑒 3𝑛(12𝑛+1)
𝜋𝑛

> 0.7/√𝑛.
192 Chapter 18. Coin-Flipping Magic

Next we upper-bound the probability of never reaching a goal state within 𝑡


steps:
(1 − Pr{reaching goal state in one step})𝑡 ≤ (1 − 0.7/√𝑛)𝑡 ≤ 𝑒−0.7 𝑡/√𝑛 ,
using the fact that (1 − 𝑥)𝑡 ≤ 𝑒−𝑥𝑡 for all 0 ≤ 𝑥 ≤ 1 and 𝑡 ≥ 0. Hence, the proba-
bility of obtaining a balanced configuration within 𝑡 steps is at least 1 − 𝑒−0.7 𝑡/√𝑛 .
Therefore, within 𝑡 = √𝑛 steps, we reach a balanced configuration with constant
probability, and within 𝑡 = (𝑐/0.7)√𝑛 ln 𝑛 steps, we reach a balanced configura-
tion with probability 1 − 1/𝑛𝑐 for any constant 𝑐 > 0.

18.7.2 Deterministic Strategy. At first glance, a fast deterministic strategy


may not be obvious. Nonetheless, our deterministic strategy is simple: the magi-
cian flips the first coin, then the second coin, then the third, and so on (or in any
permutation thereof), until reaching a balanced configuration. With the strategy
in hand, its analysis is a straightforward continuity argument:

Theorem 18.4. Using the deterministic strategy, the magician balances 𝑛 coins in
at most 𝑛 − 1 coin flips.

Proof. Let 𝑑𝑖 denote the number of heads minus the number of tails after the 𝑖th
coin flip in the deterministic strategy. In particular, 𝑑0 is the imbalance of the
initial configuration. If we reach 𝑛 flips, we would have flipped all coins, so 𝑑𝑛 =
−𝑑0 . Thus 𝑑0 and 𝑑𝑛 have opposite signs (or are possibly both 0). We also know
that |𝑑𝑖 − 𝑑𝑖−1 | = 1. By the discrete intermediate value theorem (Johnsonbaugh,
1998), 𝑑𝑖 = 0 for some 𝑖 with 0 ≤ 𝑖 < 𝑛. Thus, the magician reaches a balanced
configuration after 𝑖 ≤ 𝑛 − 1 flips.
This deterministic strategy is fast, but still takes the square of the time re-
quired by the randomized strategy. In contrast, for equalizing all coins, random-
ization would help by only a constant factor in expectation. Is there a better deter-
ministic strategy for reaching a balanced configuration? The answer is negative,
even for strategies that flip multiple coins in a single move, using results from
coding theory:

Theorem 18.5. Every deterministic strategy for balancing 𝑛 coins makes at least
𝑛 − 1 moves in the worst case.

Proof. A general deterministic strategy can be viewed as a list of 𝑘-bit vectors


𝑠0 , 𝑠1 , . . . , 𝑠𝑘−1 , where 0’s represent coins in their original state and 1’s represent
coins flipped from their original state. For example, our (𝑛 − 1)-flip strategy is
given by the 𝑛 vectors
𝑠𝑖 = (1, 1, . . . , 1 0,
⏟⎵⏟⎵⏟ 0, . . . , 0),
⏟⎵⏟⎵⏟ 0 ≤ 𝑖 < 𝑛.
𝑖 𝑛−𝑖
Nadia Benbernou et al. 193

For a strategy to balance any initial configuration given by a bit vector 𝑥,


where 0’s represent heads and 1’s represent tails, 𝑥 ⊕ 𝑠𝑖 must have exactly 𝑛/2
1’s for some 𝑖, where ⊕ denotes bitwise xor (addition modulo 2). In other words,
every bit vector 𝑥 must differ in exactly 𝑛/2 bits from some 𝑠𝑖 . (Alon et al., 1988)
proved that the optimal such “balancing” set of vectors 𝑠0 , 𝑠1 , . . . , 𝑠𝑘−1 consists of
exactly 𝑛 vectors, and therefore our (𝑛 − 1)-flip strategy is optimal.

18.8 Flipping More Coins at Once


Returning to the magic trick of flipping 𝑛 coins to become all the same, another
generalization is to allow the magician the additional flexibility of flipping more
than one coin at once. The number of coins flipped per move might be a constant
value (as considered in the next section), or might change from move to move.
In either case, we let 𝑘 denote the number of coins flipped in a move.
In this section, we consider what happens when the spectator gets to choose
how many coins the magician must flip in each move. Obviously, if 𝑛 is even, then
the spectator must choose odd values for 𝑘, or else the magician could never get
out of the odd parity class. But even then the magician is in trouble. We provide
a complete answer to when the magician can still succeed.

Lemma 18.6. If 𝑛 ≥ 5, the magician is doomed.

Proof. The spectator uses the following strategy: If the distance between the cur-
rent configuration and the all-heads or all-tails configuration is 1, then the spec-
tator tells the magician to flip three coins. Otherwise, the spectator tells the ma-
gician to flip one coin. Because 𝑛 ≥ 5, being at distance 1 from one target con-
figuration means being at distance at least 4 from the other target configuration,
and 4 > 3, so the magician can never hit either target configuration. The spec-
tator always says odd numbers, so this strategy satisfies the constraint when 𝑛 is
even.

Lemma 18.7. If 𝑛 = 3 or 𝑛 = 4, the magician can succeed.

Proof. As mentioned above, flipping 𝑘 or 𝑛 − 𝑘 coins are dual to each other. For
𝑛 = 3 or 𝑛 = 4, the spectator can only ask to flip 1 or 𝑛 − 1 coins. Thus the
magician effectively has the same control as when flipping one coin at a time.
More precisely, if the spectator says to flip one coin, the magician flips the next
coin in the 𝑘 = 1 strategy. If the spectator says to flip 𝑛 − 1 coins, the magician
flips all coins except the next coin in the 𝑘 = 1 strategy. This transformation
has effectively the same behavior because the two targets are bitwise negations
of each other.
194 Chapter 18. Coin-Flipping Magic

Despite this relatively negative news, it would be interesting to characterize


the sequences of 𝑘 values for which the magician can win. Such a characteriza-
tion would provide the magician with additional flexibility and variability for the
equalizing trick. In the next section, we make partial progress toward this goal
by showing that the magician can succeed for most fixed values of 𝑘.

18.9 Flipping Exactly 𝑘 Coins at Once


In this section we characterize when the magician can equalize 𝑛 coins by flip-
ping exactly 𝑘 coins in each move. Naturally, we must have 0 < 𝑘 < 𝑛, because
both 0-flip and 𝑛-flip moves cannot equalize a not-already-equal configuration.
Also, as observed in the previous section, we cannot have both 𝑛 and 𝑘 even, be-
cause then we could never change an odd-parity configuration into the needed
even parity of an all-equal configuration. We show that these basic conditions
suffice for the magician.

Theorem 18.8. The magic trick with 𝑘-flip moves can be performed if and only if
0 < 𝑘 < 𝑛 and either 𝑛 or 𝑘 is odd. The optimal solution sequence uses exactly
2𝑛−1 − 1 moves in the worst case.

A lower bound of 2𝑛−1 − 1 follows in the same way as Section 18.5. Again
we can view the trick on the 𝑛-dimensional hypercube, where 0 represents a bit
unchanged from its initial configuration and 1 represents a changed bit. The
difference is that now moves (edges) connect two configurations that differ in
exactly 𝑘 bits. The lower bound of 2𝑛−1 − 1 follows because we need to visit every
bit string or its complement among 2𝑛 possibilities.
Our construction of a (2𝑛−1 − 1)-move solution is by induction on 𝑛. If 𝑘
is even, we can consider only odd values of 𝑛. The base cases are thus when
𝑛 = 𝑘 + 1 for both even and odd 𝑘. The 𝑛 = 𝑘 + 1 case has 𝑘 = 𝑛 − 1, so it is
effectively equivalent to 𝑘 = 1 from Section 18.5. We will, however, need to prove
some additional properties about this solution.
It seems difficult to work with general solutions for smaller values of 𝑛, so we
strengthen our induction hypothesis. Given a solution to a trick, we call a con-
figuration destined for heads if the solution transforms that configuration into
the all-heads configuration (and never all-tails), and call it destined for tails if
it transforms into all-tails (and never all-heads). (Because our solutions are al-
ways optimal length, they only ever reach one all-heads configuration or one all-
tails configuration, never both, even if run in entirety.) We call a transformation
destiny-preserving if every configuration on 𝑛 coins has the same destiny before
and after applying the transformation. A transformation is destiny-inverting if
every configuration on 𝑛 coins has the opposite destiny before and after applying
the transformation. Now the stronger inductive statement is the following:
Nadia Benbernou et al. 195

(1) for 𝑛𝑘 even, flipping the first 𝑗 coins for even 𝑗 < 𝑘 preserves destiny, while
flipping the first 𝑗 coins for odd 𝑗 < 𝑘 inverts destiny; and
(2) for 𝑛𝑘 odd, flipping the first 𝑗 coins for even 𝑗 < 𝑘 inverts destiny, while
flipping the first 𝑗 coins for odd 𝑗 < 𝑘 preserves destiny, and flipping coins
2, 3, . . . , 𝑘 preserves destiny.
To get this stronger induction hypothesis started, we begin with the base case.

Lemma 18.9. For any 𝑘 > 0, the 𝑘-flip trick with 𝑛 = 𝑘 + 1 coins has a solution
sequence of length 2𝑘 − 1 such that flipping the first 𝑗 coins for even 𝑗 < 𝑘 preserves
destiny, while flipping the first 𝑗 coins for odd 𝑗 < 𝑘 inverts destiny.

Proof. The construction follows the Gray code of Section 18.5. That flip sequence,
ignoring the first coin, can be described recursively by
𝐺𝑘 = 𝐺𝑘−1 , “flip the (𝑛 − 𝑘 + 1)-st coin”, 𝐺𝑘−1 .
To flip 𝑛 − 1 coins in each move, we invert this sequence into
𝐺𝑘̄ = 𝐺𝑘−1̄ , “flip all but the (𝑛 − 𝑘 + 1)-st coin”, 𝐺𝑘−1
̄ .
In the base case, 𝐺0 = 𝐺0̄ = ∅. Validity of the solution follows as in Section 18.5;
indeed, for any starting configuration, the number of moves performed before the
configuration becomes all-heads or all-tails is the same in sequences 𝐺𝑘 and 𝐺𝑘̄ .
Every move flips the first coin, so the destiny of a configuration is determined
by its parity and the parity of 𝑛: if 𝑛 and the number of coins equal to the first coin
(say heads) have the same parity, then the configuration is destined is that value
(heads); and if 𝑛 and the (heads) count have opposite parity, then the destiny is the
opposite value (tails). To see why this is true, consider the hypercube viewpoint
where 0’s represent coins matching the initial configuration and 1’s represent
flipped coins in an execution of 𝐺𝑘 (not 𝐺𝑘̄ ). Then, at all times, the number of
1-bits in the configuration has the same parity as the number of steps made so
far. At the same time, every move in 𝐺𝑘̄ flips the first coin, so the first coin in the
current configuration matches its original value precisely when there have been
an even number of steps so far. Thus, when we reach a target configuration of all-
heads or all-tails, it will match the original first coin precisely if there have been
an even number of steps so far, which is equivalent to there being an even number
of 1-bits in the 𝐺𝑘 view, which means that the initial and target configurations
differ in an even number of bits. In this case, the initial and target configurations
have the same parity of coins equal to their respective first coins; but, in the target
configuration, all coins match the first coin, so in particular 𝑛 has the same parity
as the number of coins equal to the first coin. We have thus shown this property
to be equivalent to the target configuration matching the initial first coin.
It remains to verify the flipping claims. Flipping the first 𝑗 coins for even
𝑗 < 𝑘 preserves the parity of the number of heads as well as the number of tails,
196 Chapter 18. Coin-Flipping Magic

but inverts the first coin, so inverts the destiny. Flipping the first 𝑗 coins for odd
𝑗 < 𝑘 changes the parity of the number of heads as well as the number of tails,
and inverts the first coin, which together preserve the destiny.
With this base case in hand, we complete the induction to conclude Theo-
rem 18.8. In the nonbase case, 𝑛 > 𝑘 + 2. There are three cases to consider:

Case 18.9.1. Both 𝑛 and 𝑘 are odd. By induction, we obtain a solution sequence
𝜎′ of length 2𝑛−2 − 1 for 𝑛′ = 𝑛 − 1 satisfying the destiny claims. We view 𝜎′ as
acting on only the last 𝑛 − 1 of our 𝑛 coins. Then we construct a solution 𝜎 for 𝑛
as follows:
𝜎 = 𝜎′ , “flip the first 𝑘 coins”, 𝜎′ .
This solution has length |𝜎| = 2 |𝜎′ | + 1 = 2𝑛−1 − 1.
Next we prove that sequence 𝜎 solves the trick. Consider any configuration
on 𝑛 coins, and assume by symmetry that the last 𝑛 − 1 of its coins are destined
for heads in 𝜎′ . If the first coin is also heads, then the magician arrives at the
all-heads configuration within the first 𝜎′ prefix of 𝜎. If the first coin is tails, then
the 𝜎′ prefix will not complete the trick, at which point the magician flips the
first 𝑘 coins. This move has the effect of flipping the first coin to heads as well as
flipping the first 𝑘 − 1 of the 𝜎′ subproblem, which is destiny-preserving because
𝑘 − 1 is even and (𝑛 − 1)𝑘 is even. Therefore, during the second 𝜎′ , the magician
will arrive at the all-heads configuration.
Now we verify the destiny claims. Note that the destiny of a configuration in
𝜎 equals the destiny of the last 𝑛 − 1 coins in 𝜎′ , so we can apply induction almost
directly. Flipping the first 𝑗 coins for even 𝑗 < 𝑘 flips the first 𝑗 − 1 of the last
𝑛 − 1 coins, which inverts destiny by induction because 𝑗 − 1 is even and (𝑛 − 1)𝑘
is even. Similarly, flipping the first 𝑗 coins for odd 𝑗 < 𝑘 preserves destiny by
induction. Finally, flipping coins 2, 3, . . . , 𝑘 flips the first 𝑘 − 1 coins of the last
𝑛 − 1 coins, which preserves destiny by induction because 𝑘 − 1 is even.

Case 18.9.2. For 𝑛 even and 𝑘 odd, by induction we again obtain a solution se-
quence 𝜎′ of length 2𝑛−2 − 1 for 𝑛′ = 𝑛 − 1, viewed as acting on only the last 𝑛 − 1
coins. We construct a solution 𝜎 for 𝑛 as follows:
𝜎 = 𝜎′ , “flip coins 1, 3, 4, . . . , 𝑘 + 1”, 𝜎′ .
Again 𝜎 has length 2𝑛−1 − 1. Flipping coins 1, 3, 4, . . . , 𝑘 + 1 has the effect of
flipping the first 2, 3, . . . , 𝑘 of the last 𝑛 − 1 coins, which by induction is destiny-
preserving because (𝑛 − 1)𝑘 is odd. Thus, if the destiny of 𝜎′ does not match the
first coin, then it will match the newly flipped first coin during the second 𝜎′ . As
before, destiny in 𝜎 matches destiny in 𝜎′ on the last 𝑛−1 coins. Flipping the first
𝑗 coins for even 𝑗 < 𝑘 flips the first 𝑗 − 1 of the last 𝑛 − 1 coins, which preserves
destiny by induction because 𝑗 − 1 is odd and (𝑛 − 1)𝑘 is odd. Similarly, flipping
the first 𝑗 coins for odd 𝑗 < 𝑘 inverts destiny by induction.
Nadia Benbernou et al. 197

Case 18.9.3. For 𝑛 odd and 𝑘 even, by induction we obtain a solution sequence 𝜎′
of length 2𝑛−3 − 1 for 𝑛′ = 𝑛 − 2, which we view as acting on only the last 𝑛 − 2
coins. Then we construct a solution 𝜎 for 𝑛 as follows:
𝜎 = 𝜎′ , “flip the first 𝑘 coins”,
𝜎′ ,“flip coins 1, 3, 4, . . . , 𝑘 + 1”,
𝜎′ ,“flip the first 𝑘 coins”, 𝜎′ .
This solution has length |𝜎| = 4 |𝜎′ | + 3 = 2𝑛−1 − 1. Restricting our attention
to the first two coins, 𝜎 first flips both coins, then flips the first coin only, then
flips both coins again. Together these enumerate all possibilities for the first two
coins. Restricting to the last 𝑛 − 2 coins, these moves correspond to flipping the
first 𝑘 − 1 coins, coins 2, 3, . . . , 𝑘, and again the first 𝑘 − 1 coins. By induction,
all three of these operations preserve destiny because 𝑘 − 1 and (𝑛 − 2)𝑘 are odd.
Therefore, all three executions of 𝜎′ produce the same target configuration (all-
heads or all-tails) which will eventually match one of the combinations of the
first two coins. Flipping the first 𝑗 coins for even 𝑗 < 𝑘 flips the first 𝑗 − 2 of the
last 𝑛 − 2 coins, which preserves destiny by induction because 𝑗 − 2 is even and
(𝑛 − 1)𝑘 is odd. Similarly, flipping the first 𝑗 coins for odd 𝑗 < 𝑘 inverts destiny
by induction.

This concludes the inductive proof of Theorem 18.8.

18.10 Permuting Coins Between Flips


Our final variation of the coin-flipping magic trick is parameterized by a group 𝐺
of permutations on {1, 2, . . . , 𝑛}. We start with 𝑛 coins, labeled 1, 2, . . . , 𝑛, in initial
orientations decided by the spectator. At each step, the blindfolded magician can
choose an arbitrary collection of coins to flip. Prior to flipping the coins, the
spectator chooses an arbitrary permutation from the permutation group 𝐺, and
rearranges the coins according to that permutation. The spectator then flips the
coins at the locations specified by the magician. The magician then asks, “Are
the coins all the same?”, and the trick ends if the answer is positive.
Whether the magician has a winning strategy depends on the permutation
group 𝐺. In this section, we will characterize exactly which permutation groups
allow the magician to perform such a trick. Our characterization also applies
to the superficially easier version of the trick where the spectator flips the coins
specified by the magician before permuting the coins, because we consider de-
terministic strategies.
Our characterization of valid groups turns out to match the existing notion
of “2-groups”. A group 𝐺 is a 2-group if the number |𝐺| of its group elements is
an exact power of 2. The simplest example of such a group is the cyclic group 𝐶2𝑘
198 Chapter 18. Coin-Flipping Magic

of order 2𝑘 , that is, a rotating table of coins with 2𝑘 coins. Another simple exam-
ple is the dihedral group 𝐷2𝑘 of symmetries of a regular 2𝑘 -gon (acting as a per-
mutation group on the vertices), that is, allowing the spectator to confuse “left”
(counterclockwise on the table) from “right” (clockwise on the table). A more
sophisticated example is the iterated wreath product of 𝑘 copies of the group 𝑆2
of permutations on two elements. This group can be viewed as permutations on
the 2𝑘 leaves of a perfect binary tree, generated by reversal of the leaves beneath
any internal node in the tree. Of course, we can also obtain a 2-group by taking
direct products of 2-groups.

Theorem 18.10. The magician can successfully perform the 𝑛-coin trick with per-
mutation group 𝐺 if and only if 𝐺 is a 2-group. In this case, the worst-case optimal
solution sequence makes exactly 2𝑛−1 − 1 moves.

To prove this theorem, it is convenient to speak in the language of group


representations. For a group 𝐺 and a field 𝔽, an 𝑛-dimensional 𝔽-representation
of 𝐺 is an 𝑛-dimensional 𝔽-vector space 𝑉 together with a left action of 𝐺 on 𝑉
such that 𝑔(𝑣 + 𝜆𝑤) = 𝑔𝑣 + 𝜆𝑔𝑤 for all 𝑔 ∈ 𝐺 and 𝑣, 𝑤 ∈ 𝑉 and 𝜆 ∈ 𝔽. (A left
action is a function 𝐺 × 𝑉 → 𝑉 such that (𝑔ℎ)𝑣 = 𝑔(ℎ𝑣) for all 𝑔, ℎ ∈ 𝐺 and
𝑣 ∈ 𝑉.)
In the context of our magic trick, we have a permutation group 𝐺 on the
coins; call the coins 1, 2, . . . , 𝑛 for simplicity. The vector space 𝑉 = (𝔽2 )𝑛 repre-
sents all possible configurations of the 𝑛 coins. We consider the 𝔽2 -representation
of 𝐺 on 𝑉 defined by 𝑔(𝑣1 , 𝑣2 , . . . , 𝑣𝑛 ) = (𝑣𝑔(1) , 𝑣𝑔(2) , . . . , 𝑣𝑔(𝑛) ). In other words, a
group action 𝑔 simply permutes the coins. In this algebraic language, we can
view one move in the magic trick as follows. Suppose the current configuration
of coins is 𝑣 = (𝑣1 , 𝑣2 , . . . , 𝑣𝑛 ) ∈ 𝑉, where 𝑣𝑖 is 0 if the 𝑖th coin is heads and 1 if
it is tails. The blindfolded magician specifies a vector 𝑤 = (𝑤1 , 𝑤2 , . . . , 𝑤𝑛 ) ∈ 𝑉,
where 𝑤𝑖 is 1 if the magician specifies to flip the 𝑖th coin and 0 otherwise. The
spectator then picks a permutation 𝑔 ∈ 𝐺, applies that permutation to 𝑣, and ap-
plies the flips specified by 𝑤 to 𝑔(𝑣). Hence the resulting configuration is 𝑔(𝑣)+𝑤.
If 𝑔(𝑣) + 𝑤 = (0, 0, . . . , 0) = 0⃗ ∈ 𝑉 (all heads) or 𝑔(𝑣) + 𝑤 = (1, 1, . . . , 1) = 1⃗ ∈ 𝑉
(all tails), then the magician has succeeded.
Our proof of Theorem 18.10 consists of three lemmas. The first lemma shows
that, if 𝐺 is not a 2-group, then the magician cannot guarantee a successful perfor-
mance of the trick. Next we define the notion of a “𝐺-invariant flag”. The second
lemma shows that the existence of 𝐺-invariant flag on 𝑉 implies a winning strat-
egy for the magician. The third lemma establishes that 𝑉 has a 𝐺-invariant flag
if 𝐺 is a 2-group. Together, these three lemmas prove the theorem.

Lemma 18.11. If 𝐺 is not a 2-group, then the magician is doomed.


Nadia Benbernou et al. 199

Proof. Suppose 𝐺 is not a 2-group, i.e., |𝐺| is not a power of 2. Thus there is an
odd prime 𝑝 that divides |𝐺|. By Cauchy’s group theorem, there is a permuta-
tion 𝑔 ∈ 𝐺 of order 𝑝, i.e., for which 𝑔𝑝 is the smallest power of 𝑔 that equals
the identity permutation. The order of a permutation is the least common mul-
tiple of its cycle lengths in its disjoint-cycle decomposition, and 𝑝 is prime, so
there must in fact be a cycle of length 𝑝, i.e., a coin 𝑖 ∈ {1, 2, . . . , 𝑛} such that 𝑖,
𝑔(𝑖), 𝑔2 (𝑖), . . . , 𝑔𝑝−1 (𝑖) are all distinct, while 𝑔𝑝 (𝑖) = 𝑖. We can assume by renaming
some of the coins that this cycle appears among the first 𝑝 coins:
𝑖 = 1, 𝑔(𝑖) = 2, 𝑔2 (𝑖) = 3, . . . , 𝑔𝑝−1 (𝑖) = 𝑝.
We define the set 𝑋 of “trouble configurations” to consist of configurations
in which the first three coins are not all equal, i.e., 𝑋 = { 𝑥 ∈ 𝑉 ∶ (𝑥1 , 𝑥2 , 𝑥3 ) ∉
{(0, 0, 0), (1, 1, 1)} }. The spectator chooses a configuration in 𝑋 as the initial
configuration. We next give a strategy for the spectator that guarantees staying
within 𝑋, no matter how the magician moves. This strategy then foils the ma-
gician, because not all the coins can be equal if the first three coins are never
equal.
Consider any trouble configuration 𝑥 ∈ 𝑋 and magician move 𝑤 ∈ 𝑉. We
need to show that the spectator has a move ℎ ∈ 𝐺 resulting in configuration
ℎ(𝑥) + 𝑤 ∈ 𝑋. Look at the magician moves for the first three coins: 𝑤1 , 𝑤2 , 𝑤3 .
There are eight possibilities for these three bits. We can factor out a symmetry
by letting 𝑎 ∈ {0, 1} be arbitrary and letting 𝑏 = 1 − 𝑎. Then the three bits have
four possible patterns: 𝑎𝑎𝑎, 𝑎𝑎𝑏, 𝑎𝑏𝑎, and 𝑎𝑏𝑏. The 𝑎𝑎𝑎 pattern flips none or
all of the first three coins, which means they remain not all equal, and thus the
configuration remains in 𝑋 if the spectator chooses the identity permutation (i.e.,
does not permute the coins). Three patterns remain: 𝑎𝑎𝑏, 𝑎𝑏𝑎, and 𝑎𝑏𝑏.
The cyclic sequence 𝑥1 , 𝑥2 , . . . , 𝑥𝑝 of 𝑝 bits forming the 𝑝-cycle in 𝑔 consists
of an odd number of bits. Because 𝑥 ∈ 𝑋, at least one of these bits is 0 and at least
one is 1, Thus both the patterns 𝑐𝑐𝑑 and 𝑒𝑓𝑓 must occur in the cyclic sequence,
where 𝑑 = 1 − 𝑐 and 𝑓 = 1 − 𝑒. Now, if 𝑤1 , 𝑤2 , 𝑤3 has pattern 𝑎𝑏𝑎 or 𝑎𝑏𝑏, we
use the 𝑐𝑐𝑑 pattern; and if 𝑤1 , 𝑤2 , 𝑤3 has pattern 𝑎𝑎𝑏, we use the 𝑒𝑓𝑓 pattern.
In either case, say the latter pattern appears as (𝑥𝑘+1 , 𝑥𝑘+2 , 𝑥𝑘+3 ), where 𝑘 ∈
{0, 1, . . . , 𝑝 − 1}. The spectator then chooses ℎ = 𝑔𝑘 , so that ℎ(𝑥) puts the pattern
in positions 1, 2, 3. Thus ℎ(𝑥) + 𝑤 sums the two patterns, resulting in 𝑎𝑏𝑎 + 𝑐𝑐𝑑 =
𝑔ℎℎ, 𝑎𝑏𝑏 + 𝑐𝑐𝑑 = 𝑔ℎ𝑔, or 𝑎𝑎𝑏 + 𝑒𝑓𝑓 = 𝑖𝑗𝑖. In all cases, ℎ(𝑥) + 𝑤 ∈ 𝑋.
The next two lemmas use the notion of “𝐺-invariant flag”. A subspace 𝑊 ⊆ 𝑉
is 𝐺-invariant if 𝑔𝑣 ∈ 𝑊 for all 𝑣 ∈ 𝑊 and all 𝑔 ∈ 𝐺. A flag on 𝑉 is a chain
of subspaces {0}⃗ = 𝑊0 ⊂ 𝑊1 ⊂ ⋯ ⊂ 𝑊𝑛−1 ⊂ 𝑊𝑛 = 𝑉 where dim(𝑊𝑖 ) = 𝑖 for
𝑖 = 0, 1, . . . , 𝑛. A flag 𝑊0 ⊂ 𝑊1 ⊂ ⋯ ⊂ 𝑊𝑛−1 ⊂ 𝑊𝑛 is 𝐺-invariant if each 𝑊𝑖 is
𝐺-invariant.
200 Chapter 18. Coin-Flipping Magic

Next we describe the known connection between 𝐺-invariant flags and 2-


groups.

Lemma 18.12 (Miyata, 1971). If 𝐺 is a 2-group and 𝑊 is any 𝔽2 -representation of


𝐺, then there a 𝐺-invariant flag on 𝑊.

Finally, we show the connection between 𝐺-invariant flags and the magic
trick. For simplicity, we show here how to perform a more specific version of
the trick: make the coins all heads. This version requires 2𝑛 − 1 moves. A slight
modification allows the all-tails case and reduces the number of moves to 2𝑛−1 −1.
The characterization of valid groups 𝐺 remains unaffected. These move bounds
are optimal because in particular we are solving the regular 𝑛-coin game (with
⃗ from Section 18.5.
the trivial group 𝐺 = {0})

Lemma 18.13. If 𝑉 has a 𝐺-invariant flag, then the magician can make all coins
heads in 2𝑛 − 1 moves.

Proof. Suppose 𝑊0 ⊂ 𝑊1 ⊂ ⋯ ⊂ 𝑊𝑛−1 ⊂ 𝑊𝑛 is a 𝐺-invariant flag on 𝑉. Choose


any element 𝑤(𝑖) ∈ 𝑊𝑖 ⧵ 𝑊𝑖−1 for each 𝑖 = 1, 2, . . . , 𝑛. Define the move sequences
𝜎1 , 𝜎2 , . . . , 𝜎𝑛 recursively by 𝜎0 = ∅ and 𝜎𝑖 = 𝜎𝑖−1 , 𝑤(𝑖) , 𝜎𝑖−1 for 𝑖 = 1, 2, . . . , 𝑛. By
a simple induction, 𝜎𝑖 consists of 2𝑖 − 1 moves. The magician’s strategy is 𝜎𝑛 with
2𝑛 − 1 moves.
We prove by induction on 𝑖 that 𝜎𝑖 brings any initial configuration 𝑣 ∈ 𝑊𝑖 to
the all-heads configuration 0.⃗ Then, in particular, 𝜎𝑛 brings any 𝑣 ∈ 𝑊𝑛 = 𝑉 to 0.⃗
In the base case, 𝑖 = 0 and 𝑣 ∈ 𝑊0 = {0}, ⃗ so the magician has already won. In the
induction step, 𝑖 > 0, and there are two cases: 𝑣 ∈ 𝑊𝑖−1 and 𝑣 ∈ 𝑊𝑖 ⧵ 𝑊𝑖−1 . If 𝑣 ∈
𝑊𝑖−1 , then by induction the prefix 𝜎𝑖−1 of 𝜎𝑖 brings 𝑣 to 0.⃗ Otherwise, we analyze
the three parts of 𝜎𝑖 separately. In the prefix 𝜎𝑖−1 of 𝜎𝑖 , we transform configuration
𝑣′ into 𝑔(𝑣′ ) + 𝑤(𝑗) where 1 ≤ 𝑗 < 𝑖. Because 𝑊𝑖 is 𝐺-invariant, 𝑣′ ∈ 𝑊𝑖 implies
𝑔(𝑣′ ) ∈ 𝑊𝑖 . Because 𝑊𝑖−1 is 𝐺-invariant, 𝑣′ ∉ 𝑊𝑖−1 implies 𝑔(𝑣′ ) ∉ 𝑊𝑖−1 . Because
𝑤(𝑗) ∈ 𝑊𝑖−1 for 𝑗 < 𝑖, 𝑣′ ∈ 𝑊𝑖 ⧵ 𝑊𝑖−1 implies 𝑔(𝑣′ ) + 𝑤(𝑗) ∈ 𝑊𝑖 ⧵ 𝑊𝑖−1 . (In
contrapositive, 𝑔(𝑣′ )+𝑤(𝑗) ∈ 𝑊𝑖−1 implies (𝑔(𝑣′ )+𝑤(𝑗) )−𝑤(𝑗) = 𝑔(𝑣′ ) ∈ 𝑊𝑖−1 and
by 𝐺-invariance 𝑣′ ∈ 𝑊𝑖−1 .) Therefore, the configuration 𝑣′ remains in 𝑊𝑖 ⧵ 𝑊𝑖−1
throughout the prefix 𝜎𝑖−1 of 𝜎𝑖 . Next 𝜎𝑖 takes the resulting configuration 𝑣″ and
applies 𝑤(𝑖) ∈ 𝑊𝑖 ⧵ 𝑊𝑖−1 , so the resulting configuration 𝑣″ + 𝑤(𝑖) drops to 𝑊𝑖−1 .
(A simple counting argument shows that 𝑣″ = 𝑥 − 𝑤(𝑖) for some 𝑥 ∈ 𝑊𝑖−1 , and
hence 𝑣″ +𝑤(𝑖) = 𝑥 ∈ 𝑊𝑖−1 .) Finally, by induction, the second copy of 𝜎𝑖−1 brings
the configuration to 0.⃗

Acknowledgments. We thank Patricia Cahn, Joseph O’Rourke, and Gail Par-


sloe for helpful initial discussions about these problems. We thank the partici-
pants of Gathering 4 Gardner 8 for pointing us to (Laaser and Ramshaw, 1981);
Nadia Benbernou et al. 201

and Noga Alon, Simon Litsyn, and Madhu Sudan for pointing us to (Alon et al.,
1988).

Further Reading
N. Alon, E. Bergmann, D. Coppersmith, and A. Odlyzko (1988). Balancing sets
of vectors. IEEE Transactions on Information Theory, 34 (1): 128–130. DOI
10.1109/18.2610.
R. Ehrenborg and C. M. Skinner (1995). The blind bartender’s problem. Jour-
nal of Combinatorial Theory, Series A, 70 (2): 249–266. DOI 10.1016/0097-
3165(95)90092-6.
T. Etzion (1997). The depth distribution—a new characterization for linear codes.
IEEE Transactions on Information Theory, 43 (4): 1361–1363. DOI 10.1109/
18.605610.
K. Fulves (1980). The Children’s Magic Kit: 16 Easy-to-do Tricks Complete with
Cardboard Punchouts. Dover Publications, Inc., New York.
M. Gardner (1992). See the chapter, “The rotating table and other problems.”
Based on “Mathematical Games: About rectangling rectangles, parodying Poe,
and many another pleasing problems”, Scientific American, 240(2): 16–24, Feb-
ruary 1979, and the answers in “Mathematical Games: On altering the past, de-
laying the future and other ways of tampering with time”, Scientific American,
240(3): 21–30, March 1979.
F. Gray (1953). Pulse code communication. https://www.google.com/
patents/US2632058. US Patent 2,632,058.
D.-J. Guan (1998). Generalized Gray codes with applications. Proceedings of the
National Science Council, 22: 841–848.
R. Johnsonbaugh (1998). A discrete intermediate value theorem. The College
Mathematics Journal, 29(1): 42.
W. T. Laaser and L. Ramshaw (1981). The Mathematical Gardner, see the chapter,
“Probing the rotating table”, pp. 285–307. Wadsworth, Belmont, CA. Repub-
lished in 1998 by Dover in Mathematical Recreations: A Collection in Honor of
Martin Gardner, pp. 285–307.
T. Lewis and S. Willard (1980). The rotating table. Mathematics Magazine, 53(3):
174–179.
Y. Luo, F.-W. Fu, and V. K.-W. Wei (2000). On the depth distribution of lin-
ear codes. IEEE Trans. Inform. Theory, 46(6): 2197–2203. DOI 10.1109/18.
868491.
202 Chapter 18. Coin-Flipping Magic

T. Miyata (1971). Invariants of certain groups I. Nagoya Mathematical Journal,


41: 69–73. DOI 10.1017/s0027763000014069.
E. Roode (2002). Coin puzzle. Posting to Philadelphia Perl Mongers mailing list.
http://lists.netisland.net/archives/phlpm/phlpm-2002/msg00137.
html.
R. B. Yehuda, T. Etzion, and S. Moran (1993). Rotating-table games and deriva-
tives of words. Theoretical Computer Science, 108(2): 311–329. DOI 10.1016/
0304-3975(93)90196-z.
19
Three Puzzle Fonts
Erik D. Demaine
Martin L. Demaine
Belén Palop
Jason Ku

We present three mathematical fonts that illustrate mathematical constructions,


theorems, and open problems, inviting the reader to engage with the mathemat-
ics without needing mathematical background. The fonts do so by being puzzle
fonts where reading the message is a puzzle. Specifically, each letter is repre-
sented by a mathematical puzzle whose solution looks like the letter, and they
combine to make an infinite family of puzzles. With the challenge of decipher-
ing the secret message, the reader experiences mathematical problems through
puzzles. By providing an accessible medium for understanding the mathemati-
cal principles that form the basis of the font, everyone can appreciate the beau-
tiful challenge of the underlying construction, theorem, or open problem. These
fonts are part of a series that started in 2003 (Demaine and Demaine, 2003), and
is available on the web1 ; see also the survey (Demaine and Demaine, 2015).

19.1 Conveyor Belt Puzzle Font


Suppose you have a bunch of circular gears pinned to a table (disks in the plane),
as in Figure 19.1.
1 http://erikdemaine.org/fonts/

203
204 Chapter 19. Three Puzzle Fonts

Figure 19.1. Conveyor-belt problem input

When can you wrap a conveyor belt (or elastic band) around them so that
the belt touches every gear, is taut, and does not touch itself, as in Figure 19.2?

Figure 19.2. Conveyor-belt problem goal

This open problem was posed by Manual Abellanas in 2001, and was first
published in (Abellanas, 2008). It has been studied by several computational ge-
ometers, including the present authors. Perhaps the most tantalizing special case
is when all the gears have the same size. It appears that it is always possible to
wrap a conveyor belt around equal-size gears, but this problem remains open.
Recently, we designed a font to illustrate this open problem (Demaine et al.,
2010b), shown in Figure 19.3. Each letter of the font is a set of equal-size gears
with the property that exactly one conveyor-belt wrapping outlines an English
letter.
Presented with the belts, as in the left half of Figure 19.3, the font is easy to
read. But presented without the belts, as in the right half of Figure 19.3, messages
written in the font become a puzzle to read.
The intended solution to such a puzzle is to solve several instances of the
conveyor-belt problem. Another approach is to treat the pattern as a geometric
substitution cipher, look for patterns, and try to match patterns to letters. Likely
the best strategy is a combination of both.
Erik D. Demaine et al. 205

Figure 19.3. Conveyor-belt alphabet, with and


without belts

In Figures 19.4–19.9 we provide a series of such puzzles with hidden mes-


sages. These puzzles were created using a freely available web application,2 which
you can use to generate your own puzzles.

Figure 19.4. Conveyor-belt font puzzle 1

2 http://erikdemaine.org/fonts/conveyer/
206 Chapter 19. Three Puzzle Fonts

Figure 19.5. Conveyor-belt font puzzle 2

Figure 19.6. Conveyor-belt font puzzle 3


Erik D. Demaine et al. 207

Figure 19.7. Conveyor-belt font puzzle 4

Figure 19.8. Conveyor-belt font puzzle 5

Figure 19.9. Conveyor-belt font puzzle 6


208 Chapter 19. Three Puzzle Fonts

19.2 Origami Maze Puzzle Font


A new result in computational origami design is that any orthogonal maze, with
vertical walls protruding equal heights from a rectangular floor, can be folded
efficiently from a rectangle of paper just a small factor larger than the floor
(Demaine et al., 2010a). The design algorithm has been implemented as a freely
available web application:3 you can design a maze or generate one randomly, and
the application produces a crease pattern, which you can print and fold into your
design.
The crease pattern by itself provides a kind of encoding of a maze, which
can be decoded by folding. We applied this idea to encode textual messages in
crease patterns that can be decoded by folding. Figure 19.10 shows a simple font
we designed with the constraint that each character is a small orthogonal maze,
with dimensions between 0×2 and 3×2. (With larger dimensions, the font might
be easier to read, but harder to fold.)
Given the crease pattern of a message written in this font, it is a puzzle to
decipher the original text. One approach is to print and fold the crease pattern,
which provides a physical challenge. Another approach is to fold the crease pat-
tern in your head, providing a mental challenge. A third approach is to treat the
pattern as a geometric substitution cipher, look for patterns, and try to match
patterns to letters.
In Figures 19.10–19.17 we provide a series of such puzzles with hidden mes-
sages.

3 http://erikdemaine.org/fonts/maze/
Erik D. Demaine et al. 209

Figure 19.10. The 2D orthogonal maze for the


origami maze alphabet. Figure 19.12 folds into Fig-
ure 19.11, which is an extrusion of Figure 19.10.
Dark lines are mountain folds; light lines are valley
folds; bold lines delineate letter boundaries and are
not folds.

Figure 19.11. The 3D extrusion of the origami


maze alphabet
210 Chapter 19. Three Puzzle Fonts

Figure 19.12. The crease pattern of the origami


maze alphabet

Figure 19.13. Origami maze font puzzle 1


Erik D. Demaine et al. 211

Figure 19.14. Origami maze font puzzle 2

Figure 19.15. Origami maze font puzzle 3


212 Chapter 19. Three Puzzle Fonts

Figure 19.16. Origami maze font puzzle 4

Figure 19.17. Origami maze font puzzle 5


Erik D. Demaine et al. 213

19.3 Linkage Puzzle Font


What do the polygonal chains in Figure 19.18 have in common?

Figure 19.18. Four polygonal chains

In all four drawings, the sequence of vertex angles starting from the high-
lighted edge is 90∘ , 120∘ , 180∘ . The corresponding edge lengths match as well—
they are all in fact 1. Up to rotation, these are all four drawings of this sequence of
edge lengths and angles. Each drawing can be obtained from the previous draw-
ing by spinning one edge: holding one half of the chain fixed, and letting the other
half rotate by 180∘ around the edge.
In general, a fixed-angle chain is defined by a sequence of edge lengths and
measured angles between consecutive edges. Here measured angle refers to the
minimum of the two angles on either side of the vertex, which is always between
0 and 180∘ (as opposed to, say, the clockwise angle, which can be bigger). Equiv-
alently, the measured angle can be viewed as the angle between the two edges
viewed as line segments in 3D. A configuration of a fixed-angle chain is a polyg-
onal chain that has the correct sequence of edge lengths and measured angles.
(Here we consider configurations only in 2D, but configurations in 3D also make
sense.) Edge spins, as described above, are the basic moves that a fixed-angle
chain can make: any configuration can be transformed into any other by a se-
quence of edge spins.
Fixed-angle chains, and more generally fixed-angle linkages, have been stud-
ied extensively in the field of geometric folding algorithms; see, e.g., Chapters 8–9
of (Demaine and O’Rourke, 2007). They arise naturally both to represent joint
constraints in robotics and as geometric models of molecular chemistry and bi-
ology. In particular, a reasonable mechanical model of atoms in a molecule is as
a fixed-angle linkage, and the backbone of a protein can be modeled as a fixed-
angle chain. Thus, a protein folds approximately how a fixed-angle chain folds
(in 3D).
We designed a mathematical puzzle font based on fixed-angle linkages. For
each letter and number, we designed a fixed-angle unit 6-chain, consisting of ex-
actly six unit-length segments; see Figure 19.19. Thus, each chain is determined
entirely by a sequence of five measured angles. Using a computer program, we
214 Chapter 19. Three Puzzle Fonts

Figure 19.19. The complete linkage alphabet, in


the intended configurations

computed all 25 = 32 possible 2D configurations of these fixed-angle chains, cor-


responding to all possible subsets of edge spins.
Each fixed-angle chain is designed to have a unique configuration that looks
like a letter or number, and thus can be uniquely “read”. This is the puzzle:
We choose a random configuration of each letter, and the reader must flip the
edges until they find a unique letter or number. Sometimes the chain traverses
a segment twice, in which case we draw it as a doubled edge (or in the case of
“I”, a tripled edge). The two ends of each chain (occasionally at the same place)
are highlighted; this makes it possible to uniquely construct the sequence of an-
gles underlying the fixed-angle chain given just one of its random configurations.
(Knowing the end vertices is not enough to reconstruct the chain in general, but
in our font, except for “I”, the only ambiguity is when the chain forms a doubled
cycle, in which case knowing the starting/ending vertex disambiguates.)
There are at least three different fonts based on these linkages. In the solved
font (as in the title of this chapter), each linkage is in the intended configura-
tion, so the text can be read directly. In the randomized font, each linkage is in
a random configuration (occasionally the intended one), and it is a puzzle to re-
construct the text. In the angle code font, we just give the sequence of measured
angles for each chain, making for an even more challenging puzzle to reconstruct
the text.
Erik D. Demaine et al. 215

In Figures 19.20–19.25 we provide a series of randomized font puzzles with


hidden messages. These puzzles were created using a freely available web appli-
cation4 that you can use to generate your own puzzles.

Figure 19.20. Linkage font puzzle 1

Figure 19.21. Linkage font puzzle 2

Figure 19.22. Linkage font puzzle 3

4 http://erikdemaine.org/fonts/linkage/
216 Chapter 19. Three Puzzle Fonts

Figure 19.23. Linkage font puzzle 4

Figure 19.24. Linkage font puzzle 5

Figure 19.25. Linkage font puzzle 6


Erik D. Demaine et al. 217

Puzzle Solutions
Conveyor-belt font:
stleb reyevnoc aiv yevnoc .3 • rendraG nitraM evol I .2 • 9G4G .1
ksid yreve sehcuot taht tleb tuat a yb depparw eb syawla nac sksid tinu taht erutcejnoc ew .4
nuf evah .6 • elzzup fo mrof etamitlu eht era smelborp nepo .5
Origami maze font:
nuf evah .5 • ezam ym daer .4 • tebahpla ezam imagiro .3 • hparg lanogohtro yna .2 • 9G4G .1
Linkage font:
em daer .3 • 11G4G .2 • rendraG nitraM .1
nuf evah .6 • dlrow olleh .5 • gnidlof nietorp .4

Further Reading
M. Abellanas (2008). Conectando puntos: poligonizaciones y otros problemas
relacionados. Gaceta de la Real Sociedad Matematica Espanola, 11 (3): 543–
558.
E. D. Demaine and M. L. Demaine (2003). Hinged dissection of the alphabet.
Journal of Recreational Mathematics, 31: 204–207.
E. D. Demaine and M. L. Demaine (2015). Fun with fonts: Algorithmic typog-
raphy. Theoretical Computer Science, 586: 111–119. DOI 10.1016/j.tcs.
2015.01.054. http://www.sciencedirect.com/science/article/pii/
S030439751500167X. Fun with Algorithms.
E. D. Demaine and J. O’Rourke (2007). Geometric folding algorithms: linkages,
origami, polyhedra. Cambridge University Press, Cambridge–New York.
E. D. Demaine, M. L. Demaine, and J. Ku (2010a). Folding any orthogonal maze.
In Proceedings of the 5th International Conference on Origami in Science, Math-
ematics and Education.
E. D. Demaine, M. L. Demaine, and B. Palop (2010b). Findings on elasticity,
see the chapter, “Conveyer-belt alphabet”. Pars Foundation and Lars Müller,
Amsterdam–Baden.
AMS / MAA SPECTRUM

The Gathering 4 Gardner is a biannual conference founded—and for


many years organized—by Tom Rodgers to celebrate the spirit of Martin
Gardner. While primarily concerned with recreational mathematics, most
of Gardner’s intellectual interests are featured, including magic, literature,
philosophy, puzzles, art, and rationality. Gardner’s writing inspired several
generations of mathematicians by introducing us to the joy of discovery
and exploration, and the Gathering’s aim is to continue that tradition of
inspiration.
This volume, a tribute to Rodgers and Gardner, consists of papers originally
presented at the Gathering 4 Gardner meetings. Recreational mathematics
is strongly prominent with contributions from Neil Sloane, Richard Guy,
Solomon Golomb, Barry Cipra, Erik Demaine, and many others. There are
games and puzzles, including new Nim-like games, chess puzzles, coin
weighings, coin flippings, and contributions that combine art and puzzles
or magic and puzzles. Two historical articles present the stories of combi-
natorial game theory and the search for God’s number for Rubik’s Cube.
Anyone who finds pleasure in clever and intriguing intellectual puzzles will
find much to enjoy in Barrycades and Septoku.

For additional information


and updates on this book, visit
www.ams.org/bookpages/spec-100

SPEC/100

You might also like