• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 01:31
CEST 07:31
KST 14:31
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 1 - Final Week6[ASL19] Finals Recap: Standing Tall15HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0
Community News
Esports World Cup 2025 - Brackets Revealed19Weekly Cups (July 7-13): Classic continues to roll8Team TLMC #5 - Submission re-extension4Firefly given lifetime ban by ESIC following match-fixing investigation17$25,000 Streamerzone StarCraft Pro Series announced7
StarCraft 2
General
Weekly Cups (July 14-20): Final Check-up Team TLMC #5 - Submission re-extension Who will win EWC 2025? Geoff 'iNcontroL' Robinson has passed away Program: SC2 / XSplit / OBS Scene Switcher
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Sea Duckling Open (Global, Bronze-Diamond) FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series $5,100+ SEL Season 2 Championship (SC: Evo)
Strategy
How did i lose this ZvP, whats the proper response
Custom Maps
External Content
Mutation # 483 Kill Bot Wars Mutation # 482 Wheel of Misfortune Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame
Brood War
General
Corsair Pursuit Micro? BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion Pro gamer house photos Flash Announces (and Retracts) Hiatus From ASL
Tourneys
BWCL Season 63 Announcement CSL Xiamen International Invitational [Megathread] Daily Proleagues 2025 ACS Season 2 Qualifier
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
[MMORPG] Tree of Savior (Successor of Ragnarok) Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread CCLP - Command & Conquer League Project
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread The Games Industry And ATVI Stop Killing Games - European Citizens Initiative
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece Korean Music Discussion [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Ping To Win? Pings And Their…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 667 users

Math Puzzle - 7 Hats

Blogs > Slithe
Post a Reply
1 2 3 4 5 6 7 Next All
Slithe
Profile Blog Joined February 2007
United States985 Posts
Last Edited: 2010-09-09 22:38:34
September 09 2010 20:35 GMT
#1
The king of some faraway land is bored, so he decides to setup a little game for his own amusement. These are the rules of the game:

7 prisoners will be seated at a round table. Each prisoner will have a hat placed on their head. Each hat is one of seven possible colors. The prisoners can see everyone else's hat, but they cannot see their own. The prisoners will then write on a piece of paper what they think their hat color is, and hand the paper to the king.

If any of the prisoners guesses their hat color correctly, they will all go free. Otherwise, they are all executed on the spot.

If the prisoners use the naive strategy of guessing randomly, then they have a survival chance of 66%. Can you think of a strategy such that the prisoners have a 100% chance of survival?


Clarification:
1) There are no restrictions on how many of each color there are. The prisoners could all be wearing hats of the same color, or they could also all be wearing hats of different colors.
2) The prisoners cannot communicate in any way to each other after being seated on the table.
3) You know which 7 colors are in the pool of possible colors.

Edit: Karlsberg posted an almost right solution, which prompted me to post the actual solution.

+ Show Spoiler [solution] +

We assign each color a number from 0-6

Now we can say that the prisoners are essentially getting a number, c0,c1,c2,c3,c4,c5,c6.

S = (c0 + c1 + c2 + c3 + c4 + c5 + c6) modulo 7

S has seven possible values, 0-6

At this point, what each prisoner is doing is trying to guess what S is, and solving for their own number to match S.

Prisoner 0 assumes S = 0, and solves the equation c0 = S - (c1+c2+c3+c4+c5+c6)
Prisoner 1 assumes S = 1, and solves the equation c1 = S - (c0+c2+c3+c4+c5+c6)
and so on..

At least one of the 7 prisoners will assume the correct S value. That prisoner will be able to guess the correct number for their own hat.


***
Leath
Profile Blog Joined July 2006
Canada1724 Posts
September 09 2010 20:39 GMT
#2
I believe you forgot the important rule that states no prisoners can communicate in whichever way with one another.

Otherwise, the game would end readily after a few questions are asked.

I will try to think of a solution without communicating.
http://www.kongregate.com/?referrer=Sagess
Pandain
Profile Blog Joined May 2010
United States12989 Posts
Last Edited: 2010-09-09 20:48:34
September 09 2010 20:48 GMT
#3
1.Look at everyones hat, pass it around. So then you can look at other people's hats(aka, no longer your hat)

2.Say white, because that's the combination of all colors.

3.Say "Brow...*look at their reaction* I MEAN... gree...*look at their reaction. Finds approval.* Green

4.Technically, if you try to find a loophole, its just a random hat placed on their head. So they are not allowed to look at there OWN hat, by its not their hat. It's the king or someones. So they can just take it off and look at it.
seRapH
Profile Blog Joined April 2009
United States9756 Posts
September 09 2010 20:53 GMT
#4
i have a feeling that the answer isn't going to be one that'll make me go "OH THATS SMART" but rather "oh... -_-"
boomer hands
nitdkim
Profile Blog Joined March 2010
1264 Posts
September 09 2010 20:53 GMT
#5
you may have mixed up two different puzzles into one combo puzzle that doesn't make sense.
PM me if you want random korean images translated.
AcrossFiveJulys
Profile Blog Joined September 2005
United States3612 Posts
September 09 2010 20:53 GMT
#6
this is tricky. let's look at the two extreme situations:

1) all the same color. to win in this situation, your strategy must select a color inside of the colors you see on other people's heads.
2) all different colors. to win in this situation, your strategy must select a color outside of the colors you see on other people's heads.

so your strategy is going to have to be a function of the distribution of colors you see.
Nytefish
Profile Blog Joined December 2007
United Kingdom4282 Posts
September 09 2010 20:54 GMT
#7
Are they allowed to agree on a timing system beforehand?
No I'm never serious.
seRapH
Profile Blog Joined April 2009
United States9756 Posts
September 09 2010 20:57 GMT
#8
On September 10 2010 05:54 Nytefish wrote:
Are they allowed to agree on a timing system beforehand?

that won't help considering they don't even know what colors are in the pool of hats except whats in front of them. the classic puzzle i know of only involves n colors, and 2n people, in which case a timing system works.
boomer hands
LunarDestiny
Profile Blog Joined August 2008
United States4177 Posts
September 09 2010 20:58 GMT
#9
Taking out all possible forms of loopholes, how can a 100% survival rate be achieved since they all could guess incorrectly.
tissue
Profile Joined April 2009
Malaysia441 Posts
Last Edited: 2010-09-09 21:04:50
September 09 2010 20:59 GMT
#10
On September 10 2010 05:53 AcrossFiveJulys wrote:
this is tricky. let's look at the two extreme situations:

1) all the same color. to win in this situation, your strategy must select a color inside of the colors you see on other people's heads.
2) all different colors. to win in this situation, your strategy must select a color outside of the colors you see on other people's heads.

so your strategy is going to have to be a function of the distribution of colors you see.


I am bad at math but I doubt this will hit the 100% required.

I am guessing that the answer will be arrived at through a logical leap instead of math.

Question: Do they know what colors are available?
AcrossFiveJulys
Profile Blog Joined September 2005
United States3612 Posts
September 09 2010 21:02 GMT
#11
On September 10 2010 05:57 seRapH wrote:
Show nested quote +
On September 10 2010 05:54 Nytefish wrote:
Are they allowed to agree on a timing system beforehand?

that won't help considering they don't even know what colors are in the pool of hats except whats in front of them. the classic puzzle i know of only involves n colors, and 2n people, in which case a timing system works.


i think they know the colors in the pool, otherwise in the example i brought up there's no way to win 100% when all colors are different.
Aesop
Profile Joined October 2007
Hungary11291 Posts
September 09 2010 21:05 GMT
#12
I wonder how the prisoners have a chance of 66% by guessing randomly. If they pick 1 / 7 (given they know the seven available colors), they have a 14% chance of getting it right. Doing it 7 times is 100%, so statistically one should get it right.

Or am I missing something?
ModeratorNon veritas sed auctoritas facit legem. | Liquipedia: Don't ask me, I'm retired.
Klive5ive
Profile Blog Joined January 2008
United Kingdom6056 Posts
September 09 2010 21:06 GMT
#13
On September 10 2010 05:58 LunarDestiny wrote:
Taking out all possible forms of loopholes, how can a 100% survival rate be achieved since they all could guess incorrectly.

It can't.
There must be a "logical trick" based on lack of information.

If the problem is "your hat could be any of 7 colours regardles of what you see, guess what it is out of 7 colours" you could play this game a million times and never guess right.

So the "trick" must allow prisoners to pass some form of information to each other.
Don't hate the player - Hate the game
Slithe
Profile Blog Joined February 2007
United States985 Posts
September 09 2010 21:06 GMT
#14
I have updated the post with clarifications.

@tissue: They know the 7 possible colors
tissue
Profile Joined April 2009
Malaysia441 Posts
Last Edited: 2010-09-09 21:07:44
September 09 2010 21:06 GMT
#15
On September 10 2010 06:05 Aesop wrote:
I wonder how the prisoners have a chance of 66% by guessing randomly. If they pick 1 / 7 (given they know the seven available colors), they have a 14% chance of getting it right. Doing it 7 times is 100%, so statistically one should get it right.

Or am I missing something?

In case you aren't trolling it's 1 - 6/7 ^ 7 I believe, which comes to almost exactly 66%.
Flipping a coin is 50/50. Doing it twice doesn't mean you will have a confirmed heads or tails.
AcrossFiveJulys
Profile Blog Joined September 2005
United States3612 Posts
September 09 2010 21:06 GMT
#16
On September 10 2010 06:05 Aesop wrote:
I wonder how the prisoners have a chance of 66% by guessing randomly. If they pick 1 / 7 (given they know the seven available colors), they have a 14% chance of getting it right. Doing it 7 times is 100%, so statistically one should get it right.

Or am I missing something?


that's a common misconception about probability. Here's a hint as to why that's not right. If they each had 2 chances, do you think they have a 14*14 = 196% chance of winning?
0nega
Profile Joined September 2010
Germany29 Posts
Last Edited: 2010-09-09 21:11:01
September 09 2010 21:07 GMT
#17
Hello!

lurked at this site for some time and couldn't resist EDIT but didn't have the solution... EDIT
seRapH
Profile Blog Joined April 2009
United States9756 Posts
September 09 2010 21:08 GMT
#18
On September 10 2010 06:02 AcrossFiveJulys wrote:
Show nested quote +
On September 10 2010 05:57 seRapH wrote:
On September 10 2010 05:54 Nytefish wrote:
Are they allowed to agree on a timing system beforehand?

that won't help considering they don't even know what colors are in the pool of hats except whats in front of them. the classic puzzle i know of only involves n colors, and 2n people, in which case a timing system works.


i think they know the colors in the pool, otherwise in the example i brought up there's no way to win 100% when all colors are different.

even then its mathematically impossible to have a 100% correct rate PER PERSON. your hat color is not affected by anyone else's.

the only solution i can think of is if the prisoners get to talk beforehand:

The first person will write a color of a hat he sees, show it to everyone, and give it to the king. everyone else writes that same color. but this involves a form of communication, and so feels gimmicky
boomer hands
Slithe
Profile Blog Joined February 2007
United States985 Posts
September 09 2010 21:09 GMT
#19
On September 10 2010 06:05 Aesop wrote:
I wonder how the prisoners have a chance of 66% by guessing randomly. If they pick 1 / 7 (given they know the seven available colors), they have a 14% chance of getting it right. Doing it 7 times is 100%, so statistically one should get it right.

Or am I missing something?


What you just calculated is the expected number of correct guesses if they all guess randomly. They only need one correct guess, and sometimes they can all guess wrong.

The correct way to calculate their chance of survival is like this:

Each prisoner has 1/7 of getting it right, which means 6/7 chance of getting it wrong.

The probability that all prisoners are wrong is (6/7)^7.

The probability that at least one gets it right is 1 - (6/7)^7 = .66

Impervious
Profile Blog Joined March 2009
Canada4199 Posts
September 09 2010 21:09 GMT
#20
On September 10 2010 06:05 Aesop wrote:
I wonder how the prisoners have a chance of 66% by guessing randomly. If they pick 1 / 7 (given they know the seven available colors), they have a 14% chance of getting it right. Doing it 7 times is 100%, so statistically one should get it right.

Or am I missing something?

Not quite..... If the first one guesses correctly (which is a 1/7 chance), then the game is over.

If not, then the chance that the second one will guess correctly is 6/7 (chance of the first one being wrong) * 1/7 (chance of the 2nd one guessing correctly).

If the 2nd one does not get it, then the 3rd has the chance of (6/7)^2 * 1/7

The 4th then has the chance of (6/7)^3 * 1/7

etcetera.....

The chance that at least one gets it is the sum of these percentages. Which, no matter how many people there are, will never actually be 100%.
~ \(ˌ)im-ˈpər-vē-əs\ : not capable of being damaged or harmed.
1 2 3 4 5 6 7 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 1d 4h
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft580
Nina 258
NeuroSwarm 134
ProTech62
StarCraft: Brood War
Leta 836
Snow 188
Noble 88
soO 71
Dewaltoss 17
NotJumperer 9
Icarus 5
League of Legends
JimRising 894
Counter-Strike
Stewie2K1033
Super Smash Bros
amsayoshi55
Other Games
summit1g13258
shahzam1078
ViBE84
Organizations
Other Games
gamesdonequick2110
StarCraft: Brood War
UltimateBattle 70
Other Games
BasetradeTV57
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH241
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Rush1697
• Stunt544
• HappyZerGling53
Other Games
• WagamamaTV123
Upcoming Events
Esports World Cup
1d 4h
ByuN vs Astrea
Lambo vs HeRoMaRinE
Clem vs TBD
Solar vs Zoun
SHIN vs Reynor
Maru vs TriGGeR
herO vs Lancer
Cure vs ShoWTimE
Esports World Cup
2 days
Esports World Cup
3 days
Esports World Cup
4 days
CranKy Ducklings
5 days
BSL20 Non-Korean Champi…
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs Sziky
Dewalt vs Hawk
Hawk vs QiaoGege
Sziky vs Dewalt
Mihu vs Bonyth
Zhanhun vs QiaoGege
QiaoGege vs Fengzi
FEL
6 days
BSL20 Non-Korean Champi…
6 days
BSL20 Non-Korean Champi…
6 days
Bonyth vs Zhanhun
Dewalt vs Mihu
Hawk vs Sziky
Sziky vs QiaoGege
Mihu vs Hawk
Zhanhun vs Dewalt
Fengzi vs Bonyth
Liquipedia Results

Completed

CSL Xiamen Invitational
Championship of Russia 2025
Murky Cup #2

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL20 Non-Korean Championship
CC Div. A S7
Underdog Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25

Upcoming

CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
BSL Season 21
RSL Revival: Season 2
SEL Season 2 Championship
uThermal 2v2 Main Event
FEL Cracov 2025
Esports World Cup 2025
HCC Europe
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.