programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Liutauras Vilda
• Bear Bibeault
• Paul Clapham
• Jeanne Boyarsky
Sheriffs:
• Junilu Lacar
• Knute Snortum
• Henry Wong
Saloon Keepers:
• Ron McLeod
• Tim Moores
• Stephan van Hulst
• Tim Holloway
• Carey Brown
Bartenders:
• Frits Walraven
• Joe Ess
• salvin francis

# Puzzle of the night

Leverager of our synergies
Posts: 10065
(didn't want to clash with sona nagee )
Here is one of my favourite puzzles. Fairly easy, but elegant.
So what we have:
3 wizards
5 caps: 3 white and two black.
Each wizard gets a cap, they all can see other wizards caps, but not their own.
The challenge was for each of them to figure out his color.
So the caps are put on, wizards look at each other... Nothing is said, but after a while one of them tells his color.
How did he do it?

Wanderer
Posts: 18671

Rule 1: If wizard A sees that the other two have black caps, he knows he has a white cap, and says so.
Rule 2: If wizard A sees a black cap on B and a white cap on C, he waits until C has had enough time to apply rule 1, if C were to see two black caps. If C has not announced that his own cap is white, then A knows C did not see two black caps - and since A knows C sees that B has a black hat, A knows his own hat is white. If C does announce his own cap is white, then A deduces that C saw two black caps, and so A's cap is black.
Rule 3: If wizard A sees two white caps, he waits until B and C have had enough time to figure out rules 1 and 2. If neither has spoken up, then A knows that B and C don't see two black caps, and they dont see one white and one black cap. Therefore B and C both see two white cats, which means A has a white cap. If the first person to speak announces he has a white cap, he must have applied rule 2, so A has a black cap. If the first person to speak announces he has a black cap, he must have applied rule 3 (first part), and so A has a white cap.
Now revisit rule 1. If A sees two black caps, he keeps his shut until one of the others decides to apply rule 2 and announce that his own cap is white, and thereby make a fool of himself. A then calmly announces that his own cap is white, before the remaining wizard has a chance to figure out what's going on.
Revisiting rules 2 and 3: these wizards now have to evaluate how smart and guileful the other wizards are, before attempting to apply any rules. I'll leave that to others to work out if they desire.

High Plains Drifter
Posts: 7292
A programmer who writes a program to write puzzles the the programmer can solve is sad. We need to give Jim something more to do.

Ranch Hand
Posts: 4702
9
i dont get it....if i see both other wizards wear white, mine can be either white or black...unless it is something like they are both scowling or smiling at me

Ranch Hand
Posts: 479
I remember one which was really similar and a litlle bit easier
In the bag there is 5 caps, 3 white and 2 black.
The three wizards are lined up. The last wizard can see the two wizards in front of him, the second can see only the one in front of him, and the first sees nobody.They all get a cap.
No wizards can see which cap is on his own head.
The last wizard is being asked the colour of his cap, he answer: "I don't know".
The middle wizard is being asked the colour of his cap, he answer "I don't know".
The first wizard (the one who sees nobody's cap) is being asked the colour of his cap. And he answers the right answer.
How did he do?
[ April 28, 2002: Message edited by: Younes Essouabni ]
[ April 28, 2002: Message edited by: Younes Essouabni ]
[ April 28, 2002: Message edited by: Younes Essouabni ]

Younes Essouabni
Ranch Hand
Posts: 479

We know that there is 2 black cap in the bag.
If the last wizard had saw 2 black cap, he would have known that he has got a white one. Since he couldn't answer, we may deduce that the first and the second wizard are wearing at most one black cap or two white.
If the middle wizard had saw a black cap in front of him, he would have known the color of his own cap (there is at most one black cap), since he can't answer we may deduce that the first cap is white!
Smart wizards!!!

Mapraputa Is
Leverager of our synergies
Posts: 10065

Originally posted by Michael Ernest:
A programmer who writes a program to write puzzles the the programmer can solve is sad. We need to give Jim something more to do.

In this I read an unspoken assumption that there is a puzzle Jim cannot solve. I claim that if there is such, then only Jim can construct it.

Ranch Hand
Posts: 1879
let's remember that they are wizards. They are magic, therefore, although "Nothing is said", they are all reading each other's minds. So they all know which hat they are wearing, as the other wizards will tell them telepathically.
I want to be a wizard,
Jamie

Younes Essouabni
Ranch Hand
Posts: 479
Yes, but they have also magic caps (kinda like the one from Harry Potter). It doesn't let telepathic go through

Chicken Farmer ()
Posts: 1932
One wizard looks at the other two, nods if they are the same, shakes his head if they are different.
Then one wizard looks at the wizard who looked at the other two the first time, and the other one, and either shakes or nods his head. Since the wizard who first looked at the caps knows what the other one is wearing, he will know by the shake or the nod what his color is.
Of course, this would have to be done with a legally binding verbal agreement before any caps were distributed to the parties involved

Randall Twede
Ranch Hand
Posts: 4702
9
im thinking the one wizard knows because he looked at the two left over hats

Sheriff
Posts: 6037

Originally posted by Mapraputa Is:
(didn't want to clash with sona nagee ;) )
Here is one of my favourite puzzles. Fairly easy, but elegant.
So what we have:
3 wizards
5 caps: 3 white and two black.
Each wizard gets a cap, they all can see other wizards caps, but not their own.
The challenge was for each of them to figure out his color.
So the caps are put on, wizards look at each other... Nothing is said, but after a while one of them tells his color.
How did he do it?

If any wizard saw two black hats, he knows he must have a white hat. He would answer immediately.
That no one answered means there cannot be two black hats drawn.
This leaves the possibility of 1 black hat, or 0 black hats. At this point it gets less certain.
If he sees a black and a white hat, and no one has answered, he knows, becaue there can;t be 2 black hats, that he must have a white hat.
However, if he sees 2 white hats, it's unclear. Maybe he has a black hat, the other wizards haven't gotten to the previous step yet. Or maybe he also has a white hat (3 white hats) and was the first to figure out that they were at this stage.
That's the best I can do at 2:30am.
--Mark

 today's feeble attempt to support the empire Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous