199 points · by sethbannon · 11y ago · 115 comments
Bob always chooses the same as his flip, Alice always chooses the opposite of her flip.
B A
H H - Bob chooses heads, Win
H T - Alice chooses heads, Win
T H - Alice chooses tails, Win
T T - Bob chooses tails, WinThe next level is: Eve joins the game, and the coin gets another side.
I started with a truth table as well. It's pretty easy to show that if Alice (or without loss of generality Bob) uses a fixed "always guess H" or "always guess T" strategy, that wins in two cases, but in the other two cases Bob has no way to reliably win. For instance, if Alice always guesses H, then two cases become wins:
A B
H H W
H T ?
T H W
T T ?
But in the other two cases, Bob has the same T each time, so he doesn't have enough information to distinguish those cases, and thus he can't reliably guess correctly.So Alice needs to use a strategy that depends on her flip. There are only two such strategies that don't trivially reduce to a constant guess: guess what you flip or guess the opposite of what you flip. Going with the former, where Alice guesses what she flips:
A B
H H W
H T ?
T H ?
T T W
From this, clearly if Bob guesses the opposite of what he flips, someone wins in all four cases.The only other solution is to reverse the two: Alice guesses the opposite of what she flips, and Bob guesses what he flips.
This seems like a nice warm-up for other protocols that depend on agreed-upon strategy but not a secure channel for direct communication, such as Diffie Hellman or the Socialist Millionare Problem.
I was going to post a hint rather than the solution, but you beat me to the punch.
A Alice's coin
Ac Alice's choice
B Ben's coin
Bc Ben's choice
They win if A's and Bc's OR B's and Ac's are the same A Ac B Bc
T T T T W
H T T T W
T H T T W
H H T T L
T T H T W
H T H T L
T H H T W
H H H T W
T T T H W
H T T H W
T H T H L
H H T H W
T T H H L
H T H H W
T H H H W
H H H H W
It's easier to check for when they are losing: A Ac B Bc
H H T T |they both stick to their choices
H T H T |they both flip
T H T H |they both flip
T T H H |they stick
So the winning strategy is if one of them sticks to his choice and other flips it's choice.So knowing that, I just looked for what extra, non-obvious piece of information A and B had. It seems impossible to guess what the results of a coin-flip are in another room. But the players also know the result of their own flip, and so basing a strategy on that extra info is certainly going to be the answer. From there, since there are so few combinations of such a strategy, getting the right answer is pretty trivial.
I like this brain teaser (and I suspect the reason that Felton likes it as well) because it shows this general pattern for brain teasers very clearly. The "extra" piece of information is pretty obvious with a moments thought. And once you have it, the number of possible strategies using it is small enough that you can see the correct one quickly.
A lot of other brain teasers require a lot of pen and paper work even after you've guessed the "trick" in order to work through all the possiblities. So this is sort of a nice, boiled down "essence du brainteaser".
A_coin B_coin A_guess B_guess
H H ? ?
H T ? ?
T H ? ?
T T ? ?
Then I tried to fill in the guesses, given that A_guess has to be based on B_coin and vice-versa. After making Alice guess the same as her coin flip, since that's a simple thing to try first, it was clear that Bob had to guess the opposite of his coin flip for each row to have exactly one correct match.If a fixed strategy can't work, then the guesses must be decided dynamically. At the time the guess is made, only one bit of information (their own flip) is available to each participant, so each guess has to be based on that. With one bit of information, you could only choose two things: do the same, or do the inverse. The correct, asymmetric pair of strategies popped into my head at this point, and a quick truth table check confirmed it.
Then I realized if one took the "guess same" strategy and the other took the "guess opposite" strategy that would cover the bases.
This seems a bit awkward, but information theory "guessing" is called "error correction", and parity-checking is the simplest and by far most common strategy. (Advanced algorithms are fancier multidimensional parity computations) So, their two guesses are "same" and "different" (aka parity 0 and 1). A and B each are allocated one of the two strategyGuesses, and translate observedCoin+strategyGuess=hiddenCoinGuess
\exists f,g: \forall a,b: (f(b)=a) | (g(a)=b)
where f,g are the guesses and a,b are the flips. Each guess is a function of the information available to the respective player -- the outcome of his own coin flip. There's only 4 unary boolean functions: f,g \in {true,false,id,not}
The constant functions are out and order doesn't matter, so we're left with {(id,not),(id,id),(not,not)}
Here I just tried (id,not) first, but 3 choices are easy to check exhaustively.First, I assume there is an answer, and at least a moderately interesting answer.
There is no way they can communicate information post-flip, therefore they must be able to cover every possible option.
They cannot cover every possible option by deciding what to write in advance, therefore they must decide what to write based on the flip. In fact, they must both decide based on the flip or they will not gain anything.
If you decide what to write based on the flip, there are only two real choices per player: write the same as what you got, or write the other one.
That leaves you with 3 overall options. Both taking the same of these choices won't work (I skipped over the calculation because they're not interesting solutions), so they must agree to take opposite choices.
When I re-read the description and said "oh, they only have to have one correct answer between them," it was just like, "how can I make sure that when Alice is wrong then Bob is right?". The solution followed about a second later, "well if Alice guesses the same as her flip, maybe Bob guesses the opposite of his", without any logic tables or further reasoning or anything. Then I drew up the 4 possible coin flips and the resulting predictions and wins, to prove that it was correct, just in case I was somehow missing something.
Suppose Alice got Heads. Say she guesses Heads. Then when Bob gets Heads they win. When Bob gets Tails Alice is wrong so Bob needs to guess Heads when he gets Tails.
Flip the scenario around when Alice gets Tails and you get the whole strategy
For Alice to lose, Bob would have to have flipped heads. Now Bob knows, because he has discussed strategy with Alice prior to doing the flips that either Alice flipped tails, in which case she has won, or she has flipped heads, in which case she has lost. But Bob can then bet on heads, in which case he knows that he wins if Alice loses.
That was my way of reasoning things anyhow. As you can see from the other responses, there are many different ways of arriving at the right answer.
Both of them sticking to prior choice was shown not to work, leaving 8 permutations to investigate at most. But it is easier than that.
I started by assuming Alice will guess her flip result. Looking at the truth table
A B
h h :-)
h t :-(
t h :-(
t t :-)
This means the only losing possibilities are when the coins are different. Therefore Bob must guess the opposite of his flip result, to ensure no losing possibilities at all.I have to say I feel somewhat inadequate coming to the answer experimentally as opposed to what others did here.
The answer just appeared with zero awareness of any effort or reasoning that may have lead to it -- the only reasoning I perceived was in verifying the solution. So I got curious as to how intuition could solve this problem roughly on its own, or with so little help from conscious reasoning that I didn't notice it.
From the replies it seems there are two key realizations that combined could lead directly to the solution, and both realizations strike me as things that intuition would be good at noticing. The first is that each player likely has deterministic rule that is dependent on their coin, so there are only two candidate strategies per player. And the second is that the players likely have different strategies.
EDIT: To be clear, I am not downvoting because I think that this comment is unconstructive; clearly it is a useful contribution. At least as good as, and probably better than, having it appear later would be having more whitespace between the spoiler warning and the actual spoiler.
Another fun problem, probably better known, is sequential hat guessing: take 100 people in a line, arranged so that each person can see everyone in front of them, but no-one can see any of the people behind them. Everyone is given either a red or black hat to wear, but no one can see the color of their own hat, or the hat of anyone behind them. So the person at the back of the line can see everyone's hat but their own, the next person can see everyone's hat except the first person and their own, etc.
Now starting with the back of the line, each person is asked to publicly guess the color of their hat. The participants are allowed to agree upon a strategy, how many people can they guarantee guess correctly?
Things get crazy if you allow an infinite countable line of people, and put ear-muffs on anyone so that no one gets to hear anyone else's guess. Surprisingly, you can still save almost everyone (if you allow the axiom of choice).
Usually problems on "countable" structures need only finite memory (to process infinite streaming input), so this problem is rather misleading.
100 prisoners are each assigned a black or white hat, at random. As always, they cannot communicate after the hats are assigned. Then they are shown each other. None sees own hat, everyone sees everyone elses hat. Then they are led into separate rooms and each guesses their own hat color.
They win only if everybody guesses correctly. What strategy maximizes the probability of that event?
I wouldn't be surprised if this is optimal, but I also wouldn't be surprised if it's not.
Alice guesses that Bob's coin is the same as hers. Bob guesses that Alice's coin is the opposite to hers.
It's fairly straightforward. I'd like to know the computer science angle to this though.
EDIT: From the computer science that I know :
We need to find an invariant that all permutations of coin flips always satisify. Intuition tells us that Alice's coin might be the same as Bob or vice versa :
If you construct a truth table :
Alice Bob Alice's Coin same as bob Bob's opposite to Alice
H H YES NO
T T YES NO
H T NO YES
T H NO YES
The expression : Alice's coin same as Bob || Bob's opposite to Alice
Always evaluates to true. So Alice can guess her flip and Bob can guess the opposite.But what if we had Alice , Bob and George and atleast one of them had to get the other two right ?
Is there a general pattern ?
Alice Bob George
H H H
H H T
H T H
H T T
T H H
T H T
T T H
T T T
Will try and figure it out over dinner :D .Someone didn't learn about the halting problem :-)
Note: An open problem. You can look up cryptogenography for current results.
I wouldn't be shocked if W had written some excel macros, though. Even less so if Romney had.
Alice always guessing the same as what she flips and Bob always guessing different.
But - my question is this: Are there any other possible solutions to this puzzle?
Either way, I'm pretty sure this is just an Illuminati code plot from the White House to find the world's top coders and recruit them into some CIA program.
I'm more interested to know what people think about Obama's proselytizing of computer science. It seems like a great move to me. Is he going about this in a smart way? Do you think he'll get the results that he's looking for?
A says B result is the same as A result. B says A result is different from B result,
so that A covers (H,H) and (T,T), B covers (H,T) and (T, H), so always A or B is true, so they always win.
Raise campaign finance from the wealthy so that they can make it past the lesterland election[0].
Now that you have a war chest and are in the general election you just need to raise more capital from the 0.1%, buy more advertising, hire the best staff in Washington and bam!
I know this is not the coding question at hand, but a more important question on how unequal our political system is and I couldn't forgo the opportunity to ever so gently show the obvious reality - once you past the lesterland wealthy elite and get their backing, winning is only a matter of time.
I stand corrected, very nice puzzle :)
"Antitrust" is a bogus concept.
It is never and was never in the public interest.
It is also a massive violation of the rights of companies and their shareholders.
Consider that if Windows/IE were really that bad, people would have just switched more readily to a Microsoft competitor. Desktop-quality Linux would have come about/come about sooner, or something equivalent.
This is an example of the point that there is no such thing as a monopoly unless it's created through legal channels (i.e. is granted by the government).
There is no business that can't be competed against with sufficient capital.
And the global economy accumulates spare capital over time (because in the net, the species produces more than it consumes).
Even "natural monopolies" are a function of a mistaken way to implement property rights, as opposed to being "natural." Because you can always build underneath or around whatever is already there.
edit: This is a serious intellectual comment that deserves to be read. It also matters a lot for our industry. Consider Google in Europe right now.
http://birdhouse.org/beos/byte/30-bootloader/
"[...] Be was engaged in enthusiastic discussions with Dell, Compaq, Micron, and Hitachi. Taken together, pre-installation arrangements with vendors of this magnitude could have had a major impact on the future of Be and BeOS. But of the four, only Hitachi actually shipped a machine with BeOS pre-installed. The rest apparently backed off after a closer reading of the fine print in their Microsoft Windows License agreements. Hitachi did ship a line of machines (the Flora Prius) with BeOS pre-installed, but made changes to the bootloader -- rendering BeOS invisible to the consumer -- before shipping. Apparently, Hitachi received a little visit from Microsoft just before shipping the Flora Prius, and were reminded of the terms of the license."
Consider last-mile telephone lines. It's wasteful to have ten companies each spend billions of dollars digging up the same roads to lay the same cables - and it's a nearly-impossible barrier to entry for new competitors. Sure, anything is possible with "sufficient capital", but fundamentally it's an inefficient waste of time and investor money to recreate a service that already exists, and the investors will be correspondingly scarce.
Most countries have enacted legislation enforcing fairly shared use of such lines (breaking up monopolies in the process) because cooperation is fundamentally more efficient than competition as effort is not wasted in duplication.
As a result, the ISP/telco market in civilized countries has since escaped from that stagnant local maxima with its high barrier-of-entry, to a more agile, more competitive state where smaller players have a fair chance of competing. I'm not sure if this includes the USA though (c.f. Comcast/TWC merger complaints, single-ISP areas, the "Worst company in america" award, unending complaints on /r/technology &c).
The biggest drawback that I saw from the DOJ decision was that Microsoft was not allowed to innovate. Windows 98 and Active Desktop can be considered an early precursor to today's web applications like Chrome packaged apps and Firefox apps. How might the application landscape look today if XP were firmly rooted in the concept of web applications rather than native applications? The decision against Microsoft actually slowed them down and allowed them to slowly outlast their competitors.
Instead of fighting a browser war, Netscape might have pivoted and created a Chrome OS like operating system that ran on top of Windows, Linux, and Mac OS. Google might have become known for creating a rich set of web-centric APIs that Netscape OS leveraged.
Instead, Netscape got stuck in an entrenched losing battle over a product. It was myopia that defeated them. The DOJ decision delayed the inevitable and it caused Netscape to waste resources thinking they had a chance in a "fair" fight. The Web 2.0 revolution was poised to take place on the desktop rather than in the browser. As a result, I think we all have suffered a 15 year setback.
I feel in the same way that an EU decision against Google won't correct any injustices, but it might stifle innovation; and not just innovation from Google, but its competitors as well.
Wasn't the Dictator of Singapore earlier with his Sudoku?
This is a ridiculous stunt, and it sets the wrong accents. Coding is being hyped while the people who actually keep us alive and in good condition work 3 jobs and can't afford health insurance.
Meantime, Obama destroys the Constitution and betrays the People of the U.S. to the NSA and their ilk like none did before. I think I'm getting sick.