r/mathpuzzles • u/OddOliver • Jun 28 '15
The Devil's Chessboard
This is a fun one I heard from my colleague:
You're locked in a room with the devil, and your friend is waiting outside. The only thing in the room besides you and the Devil is an empty chessboard, 63 identical coins, and a magic coin, which looks identical to the other 63 and cannot be distinguised by the human eye.
He takes each of the 64 coins and places each one, randomly heads or tails, on a square of the chessboard. He tells you (truthfully) which one is the magic coin.
You must turn over exactly one coin from heads to tails or vice versa and leave the room, after which your friend comes in. She must determine which coin is the magic coin. If she does, you both go free. Otherwise, you both spend eternity at the company barbeque.
You may discuss any strategy beforehand.
EDIT: If you want a hint, try a simpler scenario: a 2x2 chessboard with only 4 coins. Can you find a way to point to an arbitrary square? I will post the solution soon, just need to write it up.
EDIT 2: Solution below!
Are you sure you want to read the solution?
Last chance to turn back! Do it now!
Trust me, if you get it on your own, it's a great feeling.
Now, we just extend to an 8x8.
EDIT 3: Rest of the solution! I'm going graphical.
Let's say we want to choose this square: http://i.imgur.com/mINNsye.png. We make the right 4 columns odd, the top 4 rows odd, then the total sum of every pair of columns odd: the sum of 1, 2, 5, and 6 odd, and rows 3, 4, 7, and 8 odd. The red represents an odd sum, and the white an even sum. http://imgur.com/2hAunD9,z7yvqef,ST9iCsE,WqIJl4c We know this must always work: if the sum of columns 1, 2, 5, and 6 starts off as even, then the sum of 3, 4, 7, and 8 must also be even! Remember, we assumed a total even sum.
Lastly, to narrow down to the individual column and row, look at second column. We make columns 1, 3, 5 and 7 odd, and rows 1, 3, 5 and 7 odd! Notice the x is always in the red (sum is odd), and not in the white (even) Convince yourself this is always possible. http://imgur.com/o3xA0jv,9kYgfle
EDIT 4: Wrap-up / method.
There's a huge wall of text, but I just went overboard with explanation. It's all the same concept of odd/even.
EDIT 5: The assumption is simple to account for. If it starts odd, flip, in your head, the top left coin as well to make it start even.
4
u/crabmilk Jun 29 '15 edited Jun 29 '15
1
u/OddOliver Jun 29 '15
Such a CS answer. Show me the money!
2
u/crabmilk Jun 29 '15 edited Jun 29 '15
It's not really a CS answer - it's rigorous and I only used binary numbers for convenience. I've fleshed out the solution more:
8
u/briseymo1 Jun 28 '15
Does the devil also tell my friend which coin is the magic coin?
Edit: Wow. I'm dumb. I read your scenario thoroughly and still asked this question. My bad!
2
3
u/bowj Jun 28 '15
My guess is you look at the 4 coins above, below, and next the magic coin. Since there is 4 coins around the magic coin there are 16 possibilities (2x2x2x2). Theres a 50% chance that the magic coin either has 3 heads or 3 tails next to it and theres only a 12.5% chance it has either 4 heads or 4 tails next to it. So I would flip the odd coin to match the other coins and tell my friend to pick the center coin. It's not a sure way, and it only works is the magic coin isn't on the side of the chessboard.
1
7
u/ShadeFinale Jun 28 '15
If you want a nice explanation to this puzzle you can look at this:
http://datagenetics.com/blog/december12014/index.html
(Which I think is the same puzzle but re-worded.)
1
u/OddOliver Jun 28 '15
Note: this is a really difficult puzzle, but very gratifying when you get it.
5
1
u/possumman Jun 28 '15 edited Jun 29 '15
Not a solution, but some thoughts.
Heads/Tails is effectively binary. There are 64 squares which is 26 meaning a row of 6 coins (e.g. the top row) could tell your partner which square to look at (e.g. H =1, T = 0). However, you can only turn one coin - this would require up to 6 to be turned over. Can someone use this/improve on this? Am I on the right lines?
1
u/OddOliver Jun 28 '15 edited Jun 28 '15
Yes, you only effectively need a binary number of length 6 to point to any square. However, this is impossible with only one flip, since the initial faces are random. What if they're all heads? Then you can only point to a large subset of the possible positions.
If you want a hint, try a simpler scenario: a 2x2 chessboard with only 4 coins. Can you find a way to point to an arbitrary square?
Lastly, please use spoilers, even if you're just guessing!
1
u/andraflandra Jun 28 '15
chess boards are 8x8
1
u/OddOliver Jun 28 '15
Yes, but you only effectively need a binary number of length 6 to point to any square. However, this is impossible with only one flip, since the initial faces are random. What if they're all heads? Then you can only point to a large subset of the possible positions.
1
u/DeDodgingEse Jun 28 '15
I don't see any solution possible! I guess I'm bad at this. Please post solution as a spoiler?
1
u/OddOliver Jun 28 '15
I'll post it, but I also want people to sweat a little :)
Also, I'm posting a hint.
1
u/xenopunk Jun 28 '15
Just a few questions before I start, Does it work 100% of the time? Is it a cheat? (i.e I put the coin sideways)
1
u/OddOliver Jun 28 '15
Yes, it works 100% of the time. It is not a cheat, straight logic. I just updated the post with a hint.
1
u/Desperoth Jun 28 '15
Are we allowed to rotate a coin when flipping it over?
1
u/OddOliver Jun 28 '15
Nope! Well, you could, I guess, but the other coins are randomly rotated as well. Nice thought, though! This is not a lateral thinking problem, more of a straightforward logic. See the hint spoiler in the original post!
1
1
u/sprite144 Jun 28 '15 edited Jun 28 '15
I've got a solution.
There are 18446744073709551616 different combinations. You make it so each combination corresponds to a space on the board. All 64 spaces have an equal amount of combinations. No matter what your board looked like and where the magic coin was you would be able to flip a coin to one of the 18446744073709551616 combinations to show which space the magic coin was on to your partner.
Only hard part is you have to remember 18446744073709551616 different combinations. : ^ )
1
1
u/SoloRubix Jun 29 '15
I'm having problems understanding the solution, specifically: In the 2x2 example, you can't always make a specific space be the only one to have both an odd row and column. In the example
1
u/Cortye Jun 29 '15
After reading your solution, I still can't quiet figure out, how this is possible. I might read it wrong, but there seems to be a huge contradiction with you saying the field is layed out randomly and your assumptions. Maybe it's the language barrier I'm struggling with.
1
u/OddOliver Jun 29 '15
1
u/Cortye Jun 29 '15
To test myself. This 3x3. Blue is the magic coin and red is the coin that needs to be flipped. (open coin is heads, crossed one is tails btw). This is because you want with the blue coin, BOTH row AND column be odd. If you look at all other coins (after you flip the red coin), now all of them are either both row and column even, or only the row OR the column is even.
1
2
u/Cortye Jun 29 '15
Wait I think I'm starting to see it. I'll need to do a few more examples of bigger squares, but I think I understand the concept. Nice puzzle! Very difficult actually!
1
u/xenopunk Jul 06 '15
While possible I dislike the wording of this scenario, the method isnt really feasible for the given situation. Maybe with practice it would be but it seems it would require a computer to help you.
1
u/OddOliver Jul 06 '15
Not true. All you have to do is add up each column and each row. That's all you need for the calculations.
1
u/TLDM I like recreational maths puzzles Jul 06 '15
Finally looked at the answer. Wow. This is an amazing problem. Thank you for posting this.
1
3
u/str8nwheel Jun 29 '15
i thought you could hold the coin long enough for it to warmth and then tell your friend to hurry and find it before it gets cold again :) thats not math though
1
u/NonstandardDeviation Jun 29 '15 edited Jun 29 '15
I personally think your visual explanation is more confusing, because it obscures the mathematical properties underlying your ability to encode information into the board. Nevertheless, it's a fun puzzle. Here's my solution, in python. http://pastebin.com/Wkxf3xB3
1111111100000000
1111000011110000
1100110011001100
1010101010101010
If you prefer it on github, here's the implementation again: https://github.com/dtyi/Cute-Math/blob/master/devil_chessboard.ipynb
1
u/EntertainmentNo5501 Apr 12 '24
Alright, it's been 5 weeks now. Chessboard Problem spoilers ahead.
Consider a vector space over GF(2) and the following linear mapping of binary vectors of dimension 64 into binary vectors of dimension 6:
[0 1 0 1 0 1 0 1 0 1]
[0 0 1 1 0 0 1 1 0 1]
M = [0 0 0 0 1 1 1 1 0 ... 1]
[0 0 0 0 0 0 0 0 1 1]
[0 0 0 0 0 0 0 0 0 1]
[0 0 0 0 0 0 0 0 0 1]
Note that M contains 64 columns corresponding to the binary representations of the integers 0-63 and the columns are unique and closed under linear combinations. Next, given a binary vector, v, of dimension 64 that represents the board state set by the warden, construct the following matrix:
v[1 1 1 ... 1 1] + I = A
The matrix V = v[1 1 1 ... 1 1] is 64 x 64 and has the board vector v for every column. Adding the identity matrix I results in each column of A corresponding to one of the possible states obtained by flipping a single square. The columns are unique since each is comprised of the vector v with a unique component "flipped".
Clearly MA gives a 6 x 64 matrix, T. If it can be shown that every column of A maps to a unique column of T then each column of T corresponds to a unique integer in the range 0-63, like M. The index of the square where the key is hidden will then correspond to one of these columns. Furthermore, the index of the column will indicate which column of A gives the answer when multiplied by M, thus indicating which square to flip.
For instance, if the key is hidden under square 10 (with 0 based indexing), and the 30th column of T (again with zero based indexing) is the binary representation of 10 ([0 1 0 1 0 0]T), then flipping square 30 will give the answer when the new board vector is multiplied by M.
So, to prove every column of A maps to a unique column of T, assume otherwise. Then there are two columns of A = V + I, ai, aj, i != j for which
Mai = Maj -> Mvi + Mei = Mvj + Mej
But vi = vj for all i, j, so
Mvi + Mei = Mvj + Mej -> Mvi + Mei = Mvi + Mej -> Mei = Mej
Notice that Mei is just the ith column of M and Mej is the jth column. Then
Mei = Mej -> mi = mj
But by construction the columns of M are unique so this is a contradiction. The columns of T are therefore unique and it is always possible to find a column representing the square where the key is hidden and thus which coin to flip.
The prisoner doing the encoding must compute MA but then after the correct flip resulting in board vector u, the other prisoner just needs to compute Mu to reveal the answer.
And really the encoding prisoner only needs to compute Mv and then find which column of M adds to Mv to give the desired answer since T = M(V + I) = [Mv ... Mv] + M.
0
u/xavortm Jun 28 '15
Its not mentioned that you cant leave signs right? That means that you can put some saliva on your finger before turning
1
0
Jun 28 '15
[deleted]
1
u/John_Q_Nippleton_III Jun 28 '15
Yea, this is pretty tough. It kinda reminds me of the 50 people in a line with black/white hats puzzle
1
u/TLDM I like recreational maths puzzles Jun 28 '15
(Assuming you're thinking of the same one I was,) I was trying to think of a solution similar to that, but I can't think of anything that will help in this situation, even after looking at the hint.
0
Jun 28 '15
[deleted]
1
u/OddOliver Jun 28 '15
I told you it's a hard problem! I posted a partial solution if you want, but in sections, so you can stop wherever you want.
16
u/TwizzlesMcNasty Jun 28 '15
It seems to me that the assumption you make to explain the solution is vital to the solution and that the question contradicts the assumption with the word random.