# Magician, assistant, nine dice, and two cups

A magician and her assistant are performing a magic show today, and you are the only audience member. Since it is a Thursday, the magician is saving her strength for the inevitable dragon attack and only performs simple tricks involving dice, coins, and cards. At 2 pm, the dragon attacks the village and the magician goes outside to fight it.

The assistant invites you to participate in the next trick, and hands you nine (six sided) dice and two identical opaque cups. Prompted by the assistant, you first carefully check that none of the dice are weighted, that they have no magnetic properties, etc., then roll them and arrange them in a horizontal line along a table. The assistant stares at the row of dice for a few minutes, then finally points to two of the nine dice (without touching them) and asks you to cover them up with the two cups.

After you cover up the indicated dice, you murder the assistant, arrange a few fake clues to make it seem like the magician was the murderer, and call the police. While the police are responding to your call, the magician stumbles back onstage, exhausted from the fight and covered in dragon blood. She doesn't notice the dead body of her assistant.

The magician stares at the row of seven visible dice and two opaque cups for a few minutes, then finally points to the first cup and says, "the die under this cup has a 5 on top." She then points at the second cup and says, "the die under this cup has a 2 on top." Both guesses are correct.

How did the magic trick work? (Note: magic is not real; the magician defeated the dragon using her sword.)

• That poor assistant! :( – Ian MacDonald Apr 16 '15 at 21:45
• OP: "Hmm, How do I make sure nobody looks for some secret communication between the magician and the assistant? Looks at Game of Thrones Oh, I have an idea..." – Poelie Apr 16 '15 at 21:54
• The encoding has to be perfectly efficient; the magician has choose(9,2)=36 choices to convey 36 possibilities. – xnor Apr 16 '15 at 22:01
• The assistant, in anticipation of her imminent death, taped a note to the bottom of the table by sleight of hand. It read: "Goodbye 2 5" – Ben Frankel Apr 16 '15 at 22:11
• Who cares about the assistant? It's this dragon murdering that needs to be stopped!! – Golden Dragon Apr 17 '15 at 13:34

Firstly arrange the dice into a 3x3 matrix. If the sum of all dice is even, choose the column of first cup according to the total sum mod 3, and the row according to the sum of its own column. Let's say the first row/column means mod 3 = 0 and the second means mod 3 = 1.

If the first cup is O (its own column denoted by o), choose the second cup between A, B (related to the position of O, and wrapping around if O touches the border) according to the parity of the column of the first cup. Say A is odd and B is even:

.oA
.O.
.oB


If the sum of all dice is odd, choose the diagonals and sum its diagonals instead. Say the main diagonal is for mod 3 = 0 and goes right, and dice in it start from top. And the second cup is chosen in this way:

o..
AO.
.Bo


To reverse this process, firstly get the two bit informations from the relative position of the two cups. (If the two cups are diagonally adjacent, then the total sum is even. One diagonal is for A and the other is for B. Otherwise it's odd, and A is horizontal while B is vertical.) Then get the two "trits" from the position of the base cup, and use the Chinese remainder theorem. For example:

11.
1.1
146


It is in the first case (two cups arranged in diagonals and the total sum is even), and the second cup is at the position of A (sum of the second column odd). The "base" cup is in the middle, which means both sums mod 3 = 1.

So for the "base" cup it is 1 - 1 - 4 = 2 (mod 3), and even (sum of the column is odd and 1 + 4 is odd). So it is 2. Similarly for the top-right cup, it is 1 - 1*5 - 4 - 6 - 2 = 2 (mod 3), and odd (total sum even and sum of others odd), so it is 5.

• Thanks, this looks good to me. One question, though: Suppose O is in top-right -- would A be bottom left and B be middle left? (That is, do the A and B positions simply wrap around? – Caleb Apr 17 '15 at 23:52
• @CalebBernard Yes, they wrap around. – user23013 Apr 17 '15 at 23:53
• Brilliant! The police see through the fake clues and arrest you, though. – zeb Apr 18 '15 at 2:05
• @zeb noooooooooooooooooooooo! – Ian MacDonald Apr 18 '15 at 4:39
• I still do not fully understand; would someone kindly elaborate? – blackened May 13 '15 at 19:12

I have a way which can safely determine one number.

Let's say first cup is called F
Let's say second cup is called S

Position on the tables are:

x x x x x F x x S
dice value of F=5
dice value of S=2

Now we place S always on the far right end of the table.
Now whatever the number on the dice is (1-6) under S that means how many dices are between those two cups.

I.e.: S is always on 9th position. If there is value of 3 underneath the S then F will be on position 5 (3 dices in between).

Now we know for sure what number is underneath S

And we determine the number under F by:

Guessing, seriously 1/6 odds are way better than 1/36. It's magic!

• I guess that's not bad if the magician expects to fail sometimes. If she claims to be infallible, though, this obviously won't solve it. – Ian MacDonald Apr 17 '15 at 18:23

EDIT: now conforms to example, also has better success rate.

This doesn't guarantee success, nor does it safely determine the identity of either die, but it gives better odds than the best current answer (@Zikato's):

Method for if there are 2 or 3 pairs initially:

Rule for assistant: Mentally sort the dice into pairs. Find the lowest value which there is a pair of, and choose the first two dice of this value to cup.

Rule for magician: Look at the visible pairs (there will be at least 1). This is an upper bound on the value of the pair under the cup. Now, say you have something like this: X334X2345. We see that the lowest visible paired value is 3, so we have it down to a 1/3 chance. Now, they can't be 3s, or else the assistant would have cupped the 1st and 2nd dice. Therefore we're looking at either two 1's or two 2's -- a 50/50 guess. If we had something like this - X332X3345 - then we'd know for sure it's two 1's, because if it was 2's, the assistant would have cupped 1st and 4th positions. This method gives, I think, at least 1/5 odds.

Method for if there are 4 pairs:

Assistant: If there are 4 pairs, cup the unpaired number first (if it is ambiguous which one is unpaired, choose the last option), then, looking at the other numbers, cup the one with the position equal to the first cup's value (jumping over any cups if needed). So if you have 243324665, cup the five, then cup the second 2. If you have 232222222, cup the three, then cup the 3rd 2 (as it is in position #3 if we ignore the cupped position).

Magician: Find the visibly unpaired number. One of the two cups will be that #. Now, look at the positions of the 2 cups. If one of them is in the 7th, 8th, or 9th position (1/3 chance I think) then that is the unmatched one. The other cup = the visible unmatched value and its position is the value of the other cup. If both cups are in the positional range from 1-6, then you know the value of a cup, but aren't sure which cup it's the value of. Take the example 2X2X22222. We know one of the cups is hiding a 2. Suppose it's the first one. This is impossible, because then we would have cupped the unpaired value at position 4 first, and then cupped the die with the position = the unpaired die's value second. We clearly cupped position 2 second, and position 4 can't hold value 2, because then the unpaired value would have been ambiguous and the assistant would have chosen the 9th position to be the unpaired one. So we know that position 2 is the unpaired one, and since the 4th position is a 2 (we know this) and it's in the 3rd position ignoring cups, then the mystery cup holds a 3. So if there are 4 pairs to begin with, we have 100% chance of success.

• This probably needs adjusting for the example in the riddle, where the numbers under the two cups don't match. – Ben Aaronson Apr 17 '15 at 22:46
• @BenAaronson Fixed -- Not only does my answer conform now, but it has better odds of success than before as well. – Caleb Apr 17 '15 at 23:07

Alternatives

Option 1:

There was no dragon. The magician covered herself in fake blood in a back room and was watching the trick the whole time.

Option 2:

The magician saw a photo/sketch of the table including the dice without the cups on top.

Option 3:

The assistant is magic and, with her dying breath, transmitted the information of the dice to the magician.

Option 4:

The magician was wearing X-Ray specs

Option 5:

The magician took a wild guess and was right.

Option 6:

The dragon, being magical itself and horribly misunderstood, tried to aid the magician by telling her about the assistant and the dice. Unfortunately, the dragon was still slain but the magician remembered the words about the dice.

Option 7:

The tabletop is glass and there was a mirror on the floor. Since opposite sides on a dice always add up to 7, it was easy for her to figure out what the dice were.

Option 8:

It's the year 5645 and humans have successfully created dragons. Big mistake. The inside of the opaque cup has a small camera with a mini light that is wirelessly linked to special contacts the magician has. Child's play to determine the dice.

Though this is kind of a loop hole it works as follows:

the first time we hear about the value of the dice is from the magician, we cannot check if it is right or wrong since we do not know if the dice were 5 and 2. for all we know the trick could be just naming 2 random numbers on the magicians part.

Other possibility:

obviously the magician and the apprentice agreed on a certain algorithm to determine what dice will be under the cup. i think to properly give this algorithm we would need to know all the values of the dice since there are multiple possibilities to do this.

one of which:

if the dice are 111115112 you simply lay out the first 5 dice so added up they give the number of the dice under the cup, if this number is greater than 6 you add mod 6, to get the 2 you do the same. Now obviously i know this does not work with several combinations of dice but as we do not know the numbers on the dice i see it as we are free to make of it what we wish

• I think you forget that it is YOU that determines the order of the dice, and the assistant that chooses to hide two. It would be interesting to see if for any random set of numbers it would be possible to determine if at least two cups could be placed like that. – Tim Couwelier Apr 17 '15 at 7:51

A wild guess but lets see if this is correct

It's a Thursday S - M - T - W - T (5th day) - F - S and at 2pm magician goes out for a fight. both the facts are known to assistant and magician so without even communication he can guess it

• I would love to hear the reason for the downvote. – Karan Thakkar Apr 17 '15 at 7:35
• We would all love that, let me get you back to 0 since it is a possible solution. – Vincent Apr 17 '15 at 7:37
• Downvote wasn't mine, but it could be possible not to have a two and a five appear in the series in that order, therefor opening up failed scenario's for the trick. Such assumptions cannot work if the numbers aren't guaranteed to come up (could be 9 1's for example and then this doesn't work) – Tim Couwelier Apr 17 '15 at 7:41
• agree and appreciate your comment @TimCouwelier – Karan Thakkar Apr 17 '15 at 7:42