• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 16:02
CEST 22:02
KST 05:02
  • 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
Classic Games #3: Rogue vs Serral at BlizzCon2[ASL20] Ro16 Preview Pt1: Ascent9Maestros of the Game: Week 1/Play-in Preview12[ASL20] Ro24 Preview Pt2: Take-Off7[ASL20] Ro24 Preview Pt1: Runway13
Community News
Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues22LiuLi Cup - September 2025 Tournaments3Weekly Cups (August 25-31): Clem's Last Straw?39Weekly Cups (Aug 18-24): herO dethrones MaxPax6Maestros of The Game—$20k event w/ live finals in Paris76
StarCraft 2
General
Team Liquid Map Contest #21 - Presented by Monster Energy Classic Games #3: Rogue vs Serral at BlizzCon [G] How to watch Korean progamer Streams. #1: Maru - Greatest Players of All Time Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues
Tourneys
LiuLi Cup - September 2025 Tournaments Maestros of The Game—$20k event w/ live finals in Paris WardiTV Mondays Sparkling Tuna Cup - Weekly Open Tournament RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around Mutation # 487 Think Fast
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ The Korean Terminology Thread Recommended FPV games (post-KeSPA) [ASL20] Ro16 Preview Pt1: Ascent FlaSh on ACS Winners being in ASL
Tourneys
[ASL20] Ro16 Group B [Megathread] Daily Proleagues [ASL20] Ro16 Group A Is there English video for group selection for ASL
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread General RTS Discussion Thread Iron Harvest: 1920+ Nintendo Switch Thread Diablo IV S10 Infernal Tides Guide
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
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread The Games Industry And ATVI UK Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
Collective Intelligence: Tea…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
INDEPENDIENTE LA CTM
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1364 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 States9760 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 States9760 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
Hungary11297 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 States9760 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
Canada4200 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
OSC
16:00
Mid Season Playoffs
NightMare vs NicoractLIVE!
SteadfastSC373
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 373
IndyStarCraft 185
UpATreeSC 118
JuggernautJason73
ProTech69
StarCraft: Brood War
Britney 24048
Calm 2361
Rain 1427
Bisu 923
Mini 552
firebathero 248
Dewaltoss 65
sSak 44
scan(afreeca) 20
NaDa 10
Dota 2
LuMiX1
Counter-Strike
fl0m1749
Stewie2K579
flusha120
allub57
Heroes of the Storm
Liquid`Hasu510
Other Games
Grubby3558
Beastyqt525
ToD225
KnowMe192
C9.Mang0169
SortOf88
Sick79
ZombieGrub53
Kaelaris8
fpsfer 1
Organizations
Other Games
gamesdonequick1921
Algost 7
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 20 non-featured ]
StarCraft 2
• 3DClanTV 90
• Reevou 7
• Dystopia_ 4
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• blackmanpl 32
• FirePhoenix25
• Pr0nogo 5
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota22459
League of Legends
• TFBlade997
Other Games
• imaqtpie1432
• Shiphtur622
Upcoming Events
OSC
3h 58m
ReBellioN vs PAPI
Spirit vs TBD
Percival vs TBD
TriGGeR vs TBD
Shameless vs UedSoldier
Cham vs TBD
Harstem vs TBD
RSL Revival
13h 58m
Cure vs SHIN
Reynor vs Zoun
Kung Fu Cup
15h 58m
TaeJa vs SHIN
ByuN vs Creator
The PondCast
16h 58m
RSL Revival
1d 13h
Classic vs TriGGeR
ByuN vs Maru
Online Event
1d 15h
Kung Fu Cup
1d 15h
BSL Team Wars
1d 22h
Team Bonyth vs Team Dewalt
BSL Team Wars
1d 22h
RSL Revival
2 days
[ Show More ]
Maestros of the Game
2 days
ShoWTimE vs Classic
Clem vs herO
Serral vs Bunny
Reynor vs Zoun
Cosmonarchy
2 days
Bonyth vs Dewalt
[BSL 2025] Weekly
2 days
RSL Revival
3 days
Maestros of the Game
3 days
BSL Team Wars
3 days
Afreeca Starleague
4 days
Snow vs Sharp
Jaedong vs Mini
Wardi Open
4 days
Sparkling Tuna Cup
5 days
Afreeca Starleague
5 days
Light vs Speed
Larva vs Soma
LiuLi Cup
6 days
Liquipedia Results

Completed

Copa Latinoamericana 4
SEL Season 2 Championship
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
Chzzk MurlocKing SC1 vs SC2 Cup #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL Polish World Championship 2025
BSL Season 21
BSL 21 Team A
EC S1
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
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.