4
Mathematical Entertainments Michael Kleber and Ravi Vakil, Editors This column is a place for those bits of contagious mathnnatics lhat travel from person to person in the community, because they are so elegant, suprising, or appealing that one has an urge to pass them on. Contributions are most welcome. Please send all submissions to the Mathematical Entertainments Editor, Ravi Vakii, Stanford University, Depariment of Mathematics, BIdg. 380, Stantord, CA 94305-2125, USA e-mail; [email protected] The Locker Puzzle Eugene Curtin and Max Warshauer S uppose I take the wallets from you and ninety-nine of your closest friends. We play the following game with them: I randomly place the wal- lets inside one hundred lockers in a locker room, one wallet in each locker, and then I let you and your friends in- side, one at a time. Each of you is al- lowed to open and look inside of up to fifty of the lockers. You may inspect the wallets you fmd there, even check- ing the driver's license to see whose it is, in an attempt to find your wallet. Wlietheryou succeed or not, you leave all hundred wallets exactly where you found them, and leave all hundred lockei-s closed, just as they were when you entered the room. You exit through a different door, and never communi- cate in any way with the other people waiting to enter the room. Your team of 100 players wins only \f enery team member finds his or her own wallet. If you discuss your strategy beforehand, can you win with a probability that isn't vanishingly small? We develop a more mathematical formulation to facilitate a precise dis- cussion of the problem. This consists of numbering our players, atid replac- ing wallets by player numbers! Our game is played between a single Player A against a Team B with 100 members, ^1, B>. . . . ,fiioo-Player A places the numbers 1,2,..., 100 randomly in lock- ers 1,2,..., 100 with one number per locker. The members of Team B are ad- mitted to the locker room one at a time. Each team member is allowed to open and examine the contents of exactly 50 lockers. Team B wins if every team member discovers the locker contain- ing his own number. Team B is allowed an initial strategy meeting. No com- munication is allowed after the initial meeting, and each team member must leave the locker room exactly as he found it. It is important to realize that the solution does not involve some trick to pass information from one player to another. We could equally well make 100 copies of the room and make an identical distribution of num- bers into lockers for each room, then ask the members of Team B to perform their searches simultaneously, with one person per room. Each individual will succeed in find- ing his own number with probability V2. If they act independently, they must get lucky 100 times in a row, and the team will win with probability only ^l/^yoo jpaj^, g needs some help! Amaz- ingly there is a strategy which gives sig- nificant probability of success for Team B. Even if we give the problem with 2H players on Team B each of whom can examine u out of 2n lock- ers, Team B can apply the strategy to succeed with probability over 30% regardless of how large a value we take for n. Your problem is to find this strategy. Searching For Ideas Let's play with some ideas using a more manageable number of players. To be as concrete as possible, let's switch to the case of 10 players on Team B, each of whom can examine .5 out of 10 lock- ers. Here random guessing by each player is already somewhat hopeless and succeeds with probability (Vi)'" = ' —. A first try to improve the probability of success is to search for a clever way to assign a set of lockers for each person to examine. Certainly we can improve over random guessing in this manner. For example if team members 1-5 ex- amined lockers 1-5, and team mem- bers 6-10 examined lockers 6-10, they would succeed provided numbers 1-5 are placed in lockers 1-5. Number 1 is placed somewhere in the fu-st 5 lock- ers with probability 5/10, then given 28 THE MATHEMATICAL INTELLIGENCER © 2006 Springer Science + Business Media. Inc.

The Locker Puzzle - University of Cambridgegw104/Locker_Puzzle.pdf · The Locker Puzzle Eugene Curtin and Max Warshauer Suppose I take the wallets from you and ninety-nine of your

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Locker Puzzle - University of Cambridgegw104/Locker_Puzzle.pdf · The Locker Puzzle Eugene Curtin and Max Warshauer Suppose I take the wallets from you and ninety-nine of your

Mathematical Entertainments Michael Kleber and Ravi Vakil, Editors

This column is a place for those bits of

contagious mathnnatics lhat travel

from person to person in the

community, because they are so

elegant, suprising, or appealing that

one has an urge to pass them on.

Contributions are most welcome.

Please send all submissions to the

Mathematical Entertainments Editor,

Ravi Vakii, Stanford University,

Depariment of Mathematics, BIdg. 380,

Stantord, CA 94305-2125, USA

e-mail; [email protected]

The LockerPuzzleEugene Curtin and Max Warshauer

Suppose I take the wallets from youand ninety-nine of your closest

friends. We play the following gamewith them: I randomly place the wal-lets inside one hundred lockers in alocker room, one wallet in each locker,and then I let you and your friends in-side, one at a time. Each of you is al-lowed to open and look inside of up tofifty of the lockers. You may inspectthe wallets you fmd there, even check-ing the driver's license to see whose itis, in an attempt to find your wallet.Wlietheryou succeed or not, you leaveall hundred wallets exactly where youfound them, and leave all hundredlockei-s closed, just as they were whenyou entered the room. You exit througha different door, and never communi-cate in any way with the other peoplewaiting to enter the room. Your teamof 100 players wins only \f enery teammember finds his or her own wallet. Ifyou discuss your strategy beforehand,can you win with a probability thatisn't vanishingly small?

We develop a more mathematicalformulation to facilitate a precise dis-cussion of the problem. This consistsof numbering our players, atid replac-ing wallets by player numbers! Ourgame is played between a single PlayerA against a Team B with 100 members,^1 , B>. . . . , fiioo- Player A places thenumbers 1,2,..., 100 randomly in lock-ers 1 ,2 , . . . , 100 with one number perlocker. The members of Team B are ad-mitted to the locker room one at a time.Each team member is allowed to openand examine the contents of exactly 50lockers. Team B wins if every teammember discovers the locker contain-ing his own number. Team B is allowed

an initial strategy meeting. No com-munication is allowed after the initialmeeting, and each team member mustleave the locker room exactly as hefound it. It is important to realize thatthe solution does not involve sometrick to pass information from oneplayer to another. We could equallywell make 100 copies of the room andmake an identical distribution of num-bers into lockers for each room, thenask the members of Team B to performtheir searches simultaneously, withone person per room.

Each individual will succeed in find-ing his own number with probabilityV2. If they act independently, they mustget lucky 100 times in a row, and theteam will win with probability onlyl̂/̂ yoo jpaj^, g needs some help! Amaz-

ingly there is a strategy which gives sig-nificant probability of success forTeam B. Even if we give the problemwith 2H players on Team B each ofwhom can examine u out of 2n lock-ers, Team B can apply the strategyto succeed with probability over 30%regardless of how large a value wetake for n. Your problem is to find thisstrategy.

Searching For IdeasLet's play with some ideas using a moremanageable number of players. To beas concrete as possible, let's switch tothe case of 10 players on Team B, eachof whom can examine .5 out of 10 lock-ers. Here random guessing by eachplayer is already somewhat hopeless andsucceeds with probability (Vi)'" = —'—.A first try to improve the probability ofsuccess is to search for a clever way toassign a set of lockers for each personto examine. Certainly we can improveover random guessing in this manner.For example if team members 1-5 ex-amined lockers 1-5, and team mem-bers 6-10 examined lockers 6-10, theywould succeed provided numbers 1-5are placed in lockers 1-5. Number 1 isplaced somewhere in the fu-st 5 lock-ers with probability 5/10, then given

2 8 THE MATHEMATICAL INTELLIGENCER © 2006 Springer Science + Business Media. Inc.

Page 2: The Locker Puzzle - University of Cambridgegw104/Locker_Puzzle.pdf · The Locker Puzzle Eugene Curtin and Max Warshauer Suppose I take the wallets from you and ninety-nine of your

that number 1 is so placed, nutnber 2is also in the first 5 with probability 4/9and so on. Following this plan, Team Bwili succeed with probabihty

5 4 3 2 1 _ 110 !( fi 7 fi 242'

While this is an improvement over ran-dom guessing, it still leaves Team Bwith slim chances. Although thescheme fails, it is worth noticing lhatif Bl fmds his number in this scheme,then /in will find his number with prob-ability 5/9 (as he will iook in 5 lockersnot including the one containing thenumber 1), but B' will fmd his withprobability only 4/9. The success orfailure of B^ can influence the proba-bilities of success of the other mem-bers. This is the first clue!

An ideal strategy would be onewhere if B] succeeds then eveiyoneelse does too. Note that this would al-low the whole team to succeed half thetime even though each individualmember fails half the time. This idealis not attainable, but perhaps you canfmd a strategy where if Bi succeeds,then everyone else is more likely tosucceed. No method of preassigninglockers will accomplish this, as if Bifinds his number in locker k anyonewith locker A- in their preassigned sethas his chances reduced. This suggeststhat the locker choices will have to de-pend on infonnation not available atthe initial meeting. The only such in-fontiation available is the mmibers aplayer fmds inside the lockers heopens. With this further hint try onemore time to find a good strategy be-fore we proceed to the solution!

Developing the SolutionOiue we realize that tlie locker Biopens at any stage can depend on whathe has found inside the lockers he hasalready opened, the number of possi-ble strategies to consider is enormous,even in the 10-player case. The strategymust tell Bl which locker to open first(10 choices), which locker to opennext if he is not lucky on the firet try(9 choices for each of the possible 9numbers he may see), which to openthird if he is not lucky on his secondattempt either (8 choices for eachof the 9 x 8 possible sequences of2 numbers he has seen so far), and so

on. So Bl alone has 10 X 9" x 8^^« x7!»x8x7 X 69x8x7x(5 possible strategies.

To compute the number of strategychoices for the whole team, we raisethis to the 10th power and get a num-ber 28,537 digits long! How aie we tochoose one?

In this section we will show that onevery simple strategy lels the team winwith remarkably high probability. Thestrategy for any one player is entirely un-reniiirkable; the magic arises from thefact that the chances of the differentplayers winning are highly correlated.Moreover, in the next section, we willshow that tlie strategy is in fact optimal.

Fortunately the good strategy issimple to implement and the choice ofthe next locker does not depend on theentire sequence of numbers seen butonly on the most recent number. Thegood strategy has player Bj start byopening locker ;. Then if he finds num-ber k at any stage and k + /, he openslocker k next. Notice that player /?;,never ojjens a locker (other than lockeri) without first finding its number, soeach time be opens a new locker hemust fuid either his own number or thenumber of another unopened locker.

Again let's look at a paiticular casewith 10 players and suppose, for exam-ple, that the munbers are distributed inthe order 6,8,9,7,2,4,1,5,10,3. Player Bifirst examines locker 1 and finds thenimiber 6. So he looks in locker 6 find-ing the nmnber 4, then locker 4 fmdingthe number 7, then finally in locker 7finding his number. When he fmds hisnumber, B\ will now know that ^o- ^4-and B-, will look in exactly the samelockers in tlie san\e cyclic order, eachfmding his number on the 4th try! Healso knows that none of tiie other i)lay-ers will waste any tries on these lockers.

We may represent any pennutationof numbers into lockers by listing thecycles. The permutation 6,8,9,7,2,4,1,5,10,3 gives the cycles (6, 4, 7, 1) (8, 5, 2)(9, 10, 3), and Team B succeeds be-cause there is no long cycle. To fmd theprobability that Team B wins, we coimtthe number of permutations of 10 num-bers with a cycle of length 6 or longer.First let's count how many have a 6-cy-cle. Choose which 6 elements go intothe 6-cycle, arrange them in cyclic or-der, and then pick an arbitrary permu-

tation ofthe remaining 4 elements. Thenumber of ways to do this is

10!5!4! 10!5!4! = 6

So 1/6 ofthe 10! permutations havea 6-cycle, and a random pennutationhas a 6-cycle with probability 1/6. Thesame argument can be used to find theprobability of a pemiutation of 1-10having a cycle of any length longer than6. (We warn that 1 he argument does notwork for counting the number of per-mutations of 1-10 with a 5-cycle (orshorter) as the permutation could havetwo 5-cycles.) A pemiutation of 10numbers has a 7-cycle with probability1/7 and so on, and the probability of acycle of length 6 or larger is 1/6 -(- 1/7 +1/8 + 1/9 + 1/10 = 1627/2520 =0.645635. This gives the probabilitythat Team B will fail, so of couree TeamB wins with probabihty 1 - 1627/2520 = 893/2520 - 0.354365. Over 35%of the time, all 10 members of Team Bfind their own wallets!

Will this idea be good enough for theinitial version with 100 players? We cando the analogous computation and seethat this pointer-following strategyworks with probability 1 - (1/51 -I-1/52 -H • • • + 1/100) - .311828.

Notice that while our strategy hasstill performed remarkably well for 100players, the probability of sm cess wasstill less than in the 10-piayer version.As we increase the number of players,does the success rate decrease to zero,or does it always stay above a certainpositive number? With 2n players and'In lockers. Team B will win providedthat the permutation of numbers inlockers has no cycle of length (̂ -h 1 orlonger. The probability of such a longcycle is 2 '̂= i ^ . By viewing this ex-pression as cm upper Riemaim sum forJ;'" —^ tir and a lower Riemium sumfor /"" - dx we obtain

In 2 -1

n + 11

x+ 1dx

So SI'.. 1

n + kr = in 2.

In 2 as =c; moreoverthe sum increases monotonically withu. So the expression 1 - SA'=I --T giv-ing the probability of success is

© 2006 Springet Science + Business Media, Inc., Volume 2B, Number 1, 2006 29

Page 3: The Locker Puzzle - University of Cambridgegw104/Locker_Puzzle.pdf · The Locker Puzzle Eugene Curtin and Max Warshauer Suppose I take the wallets from you and ninety-nine of your

monotonically decreasing to 1 - In2 =0.306853. Team B wins witii the pointer-following strategy with probability ex-ceeding 30%, regardless of the nmnberof players and lockers. Now that wehave found a good strategy, we tumour attention to whether it provides thebest possible solution.

Is Pointer-Following Optimal?We establish the optimality of pointer-following by comparing the game con-sidered above (Game 1) with a nowgame (Game 2) between the same ad-versaries, Player A and Team B. Forsimplicity wo give the argument interms of the 10-playor versions. Recallthat in Game 1 we are allowing eachplayer to examine 5 lockers. We firstmodify tliis mie and say tliat each playermust continue examining lockers imtilhe has openefl tlie locker containing hisnumber, and then he is not allowed toopon any further lockors. Team B winsif no player opens more than 5 lockers.Tliis change makes no difference lo whowins in Game 1, but it will clarify thecomparison with Game 2.

In Game 2, Player A again distrib-utes the 10 numbers at random in the10 lockers. Then all of t emu B is invitedinto the locker room together. Teammember Bi is required by the rules tostart opening lockers and continue un-til she reveals the number 1. Once shehas opened the locker containing thenumber 1, sho may not open any fur-ther lockers; then, tbo lowest-num-bered member of Team B whose num-ber has not yet been revoalod isroquired to take ovor oponing lockersuntil he finds his number and so on.Team B continues until all lockers arcopened. Again Team 13 wins if no indi-vidual team member opens more than5 lockors. Beforo procooding, we inviteyou to consider the following ques-tions: With what probability can TeamB win Game 2? What strategy shouldtho toam members omploy? Does theirchoice of strategy even matter?

Lot's sit in the locker room and ob-serve Team B in the process of playingGame 2. We record tho progress, list-ing the nmnbers in tho order in whichthey are rovealod. Our list of numbersis sufficiont to determine how manylockors were opened by each player.

For example, if we record the list 2,6,1,4,9,7,10,8,3,5, we know that player /i,rovoaled the numbors 2, G, and 1. Thenplayor B,i was required to take ovor,and he opened the lockers containingthe numbers 4, 9, 7, 10, 8, and 3, in thatorder. Then playor Br, oponod the re-maining locker containing tho number5. In this example Team B lost, asplayer B.i oponod 6 lockers. Notice thatwe will record any given ordering oftho numbers 1-10 with probability1/10!. The first number revealed is 2with probability 1/10, no matter whichlockor is opened, given that the first is2 the second will be fi with probability1/9, and so on. What strategy' is ToamB following horo? It makes absolutelyno difference! Team B can choose lock-ors at random or follow the most so-phisticated plan; we still get probabil-ity 1/10! for each of tho 10! possibleorders in whicb the numbers could berovealed. In Gamo 2 Toam B's proba-bility of success is completely indo-pondent of strategy.

To find the probability that Team Bwins, we must counl how many of the10! possible orders of the numbers1-10 ropresont wins. Wo omploy a vor-sion of the classical records-to-cyclesbijoction [fi, pl7] to assign a permuta-tion written in cycle notation to eachordering. Tho first cycle of our permu-tation consists of tho numbors oponodl)y B[ in order; the second cycle, thonumbers opened by the second lockeropener; and so on. So, for example, 2,fi,1,4,9,7,10,8,3,5 -^ (2,fi,l}(4,9,7,10,8,3)(5). Furthermore we see that each per-mutation arises in tiiis manner from aunique ordering of the numbors 1-10.We first write the poniiutation in cyclenotation, rotate each cycle so that tholowest number in the cycle is writtenlast, and then ordor the cycles sothat tiieir last numbers are in ascend-ing order. For example (9,7,8)C1,3,1O,5)(2,4,6) - (3,10,5,l)(4,6,2)(8,9,7}^3,10,5,l,4,fi,2,8,9,7. We have establisheda one-to-one correspondence betweenlists for which Team B wins and thepermutations of 1-10 with no cycles oflength greater than 5. Thus the proba-bility that Teimi B wins Game 2 is thoprobability that a randoni permutationof 1-10 has no cycle of length greaterthan 5, and we have already computed

this as 893/2520 - 0.354365. Tliis is ex-actly the probability of success forToam B in Gamo 1 using pointer fol-lowing!

Our analysis has a significant con-sequence for Game 1. Team B can takeany Game 1 strategy and adapt it toGame 2 as follows: If player B, is open-ing lockers in Game 2, he can use hisGamo 1 strategy- for choosing lockersto open, simply observing the contentswithout wasting a tum if the indicatedlockor is already opon. Thus if a strat-egy .succeeds in Gamo 1 for a particu-lar distribution of numbers into lock-ors it will also succeed in Game 2. Tfthere were a better strategy for Game1 we could apply it in Game 2 and geta better chance to win this game al.so.But this is impossible, as all strategiesfor Game 2 lead to the same probabil-ity of success.

We have one final small puzzle;Happy with their optimal strategy forGame 1, Team B began a sequence ofmatches with Player A, but they .soonfound themselves down 10 to 0. Whatdo you su.spoct Player A is doing? (Itseems that Player A subscribes to thoIntelligencer and has dovised a plan todefeat Team B.) What can Team B doto counter Player A"s plan?

History of The Locker PuzzleOur problem was initially consideredby Peter Bro Miltersen. and it appealedin his paper [4] with Anna Gal. whichwon a best paper award at the ICALPconference in 2003. Miltersen says ofthe problem, "I think it started spread-ing whon I pre.sented it to several peo-ple at Complexity 2003, which was heldin Aarhns, where 1 was a local orga-nizer." In their version there is onenumbered slip of paper for each playeron the team. Player A then colors eachslip either rod or blue. Each member ofTeam B may examine up to balf thelockers. He is then required to state orguess the color of the slip of paper withhis number. Again every toam mombermust state or guoss his color correctlyfor the team to win. Initially Miltereenexpected that Team B s probability ofsuccess would approach zero rapidlyas the number of players increased.However, Sven Skymn, a colleague ofMiltersen's at tho University of Aarhus,

3 0 THE MATHEMATICAL INTELLIGENCER

Page 4: The Locker Puzzle - University of Cambridgegw104/Locker_Puzzle.pdf · The Locker Puzzle Eugene Curtin and Max Warshauer Suppose I take the wallets from you and ninety-nine of your

brought his attention to tho boautifulpointer-following strategy. Finding thisis left as an exorcise in the paper.

Miltersen and Gal originally consid-ered the case where there are n teammembers and 2// lockers, half of themempty; each team member still gets toopon up to half of the iockers. This isa more <lifficult problem. Clearly sim-ple pointer following will not work asempty lockers do not point anywhere.It is an open question whether the win-ning probability must tend to zero forlarge n.

In [5] Navin Goyal and Michael Saksbuild on Skyum's pointer-following todevise a strategy for Team B in a moregeneral setting, varying both the pro-portion of empty lockers and the frac-tion of lockors each toam member mayopen. As tho numbor of players in-creases, their probability of success forTeam B approachos zero less rapidlythan conjectured in {4]. And fixing thenumber of players and fraction of lock-ers each may open, their probability of

winning remains nonzero even as moreempty lockers are added.

Tlie problem also appeared in JoeBuhler and Elwyn Borlokamp's puzzlecolumn in the Spring, 2004 issue of TheEmis.sarij [3], with lockers replaced byROM locations antl colored numbers re-placed by signed numbers. Horo it ispointed out that the team benefits fromtho members caiofuliy planning theirguessing strategy as well as thoir lockorsearching strategy. For exampio, ifthoro aro 2n lockers and the longest cy-cle has length n + i, tho team momberscaught in the */ + 1 cycle can guess insucii a manner that they all guess cor-rectiy or all guess incorrectly. The trickis the same as that employed in tho hatproblom of Todd Ebeii [2]. Variations oftho hat problem are doscribod in JoeBulilor's article in Ihis column [ I ] and inPeter Winkler's book [7, p66, pl20]. Thelocker problem will bo discussed in a fu-ture oditiou of Winkler's book also.

We thank Joel Spencer for intro-ducing us to the problem, and wo tiiank

Ravi Vakil and Michael Kleber for en-couraging us to write this note and pro-viding many useful suggestions.

REFERENCES[1] Joe Buhler, Hat tricks. Math. Intelligencer

24 (2002), no- 4, 44-49.

[2] Todd Ebert, http://www.cecs.csulb.edu/

-ebert/

[3] The Emissary, http://www.msri.ofg/pub(i-

cations/emissary/

[4] Anna Gal and Peter Bro Miltersen. The Cell

Probe Complexity of Succinot Data Struc-

tures. Proceedings of 30th Intemational

Colloquium on Automata. Languages and

Programming (ICALP) 2003, 332-344.

|5] Navin Goyal and Miohael Saks, A Parallel

Search Game, to appear in Random Struc-

tures and Algorithms.

[61 Richard Stanley, Enumerative Combina-

torics Vol 1. Cambridge Studies in Ad-

vanced Mathematics, 49, Cambridge Uni-

versity Press, Cambridge, 1999

[7] Peter Winkler, Mathematical Puzzles: A

Connoisseur's Collection, A K Peters, Ltd.,

Natick, MA, 2004.

MAX WARSHAUER

Department of Mathematics

Texas State University-San Marcos

San Marcos, TX 78666-4945

e-mail; [email protected]

Max Warshauer received his Ph.D. at LSU under Pierre Conner

and Is now Professor in the Mathematics Department at Texas

State, where he founded and directs Mathworks* a center for Math-

ematics and Mathematics Education, one of five programs in Texas

to receive the 2001 Texas Higher Education Star Award for Clos-

ing the Caps. Max was one ot 10 individuals in the countrv to re-

ceive the 2001 Presidential Award for Excellence in Science, Math-

ematics, and Engineering Mentoring. iHis hobbies include playing

chess, go, Ping-Pong, and bicycling. iHis research interests have

included quadratic forms, analysis of algorithms, and mathematics

education.

EUGENE CURTIN

Department of Mathematics

Texas State University-San Marcos

San Marcos, TX 78666-4945

e-mail: [email protected]

Eugene Curtin, a native of Ireland, received a Ph.D. from Brown

University in 1988 under Thomas F. Banohoff. He is currently a

professor at Texas State University. His research interests have in-

cluded difterentiai geometry, ring theory, combinatorics, and graph

theory. Eugene has been a faculty member with the Honors Sum-

mer Math Camp under Max Warshauer's directorship every sum-

mer since 1992. He enjoys mathematical games and puzzles, and

likes to piay chess, go, and backgammon. He was chess cham-

pion of Ireland in 1984 and 1985, and chess champion of Texas

in 1991, 1992, and 1998.

© 2006 Springer Science*Busirtess Media, Inc , Volume 28, Number 1. 3006 3 1