• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

The Brain Teaser Thread

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Chaotic42

Lifer
Jun 15, 2001
34,814
1,994
126
Originally posted by: JS80
can you explain this i don't even get it

Let's say that there are 100 coins in total. 10 are tails up (T). 90 are face up (F). You have:

90F
10T


Pull 10 coins out into a pile. There are now X coins tails up in your pile and (10-X) coins tails up on the rest of the table.

Flip your 10 coins over. You now have (10-x) coins that are tails up, because every coin that was F is now T and every coin that was T is now F. Let's try it out with a few numbers:

Pile: 5T + 5F = 10 total coins.
Table: 5T + 85F = 90 total coins.
Flip!
Pile: 5F + 5T = 10 total coins.
5 tails in each pile.

Pile: 1T + 9F = 10 total coins.
Table: 9T + 81F = 90 total coins.
Flip!
Pile: 9T + 1F = 10 total coins.
9 tails in each pile.

Pile: (X)T + (10-X)F = 10 total coins
Table: (10-X)T + (100-(10-X))F total coins
Flip!
Pile: (10-X)T + (X)F = 10 total coins
(10-X) tails in each pile
 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: jersiq
Originally posted by: brikis98

5 hats problem? What's that?

Oh, and your problem is Fermat's Last Theorem. I think I'll leave that one to the experts :)

Hey, you said you were bored, not me
:p

Ah, I think I found your 5 hats problem. This is similar, but not exactly the same. See if you can't come up with a solution :)
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: JonTom
Originally posted by: JS80
Originally posted by: brikis98
To keep this thread going, I'll add one more, but I hope someone else has something for the future:

After losing a battle to his rival, an angry king decided that he would execute the 50 engineers he had in his employment. He marched them out on the field and prepared to execute them, but at the last second, the king felt pity and decided to give them one last chance to live.

The king explained to the engineers that on the following day, the 50 engineers would again be marched out onto a field. They would stand in a straight line, back to front, all facing the same direction, so each man sees just the backs of the men in front of him. The king's soldiers would then put, at random, either a red or black hat on each engineer. The engineer would be able to see all the hats of the men in front of him, but not his own or those of the men behind him.

The king would then start at the back of the line - that is, the engineer who can see the other 49 engineers in front of him - and ask: "is your hat red or black?" The engineer would then answer with one word: either "red" or "black". If he gets it right, he lives. If he gets it wrong, he is immediately executed. Either way, the king moves up the line asking the same question to each engineer in turn. If an engineer says anything other than "red" or "black" or if any of the engineers cheat (try to look at their own hats), all 50 are immediately executed.

Question: what strategy can the engineers come up with to guarantee the maximum number of them survive?

the last person yells out the first, second to last the second, etc. at least half survive?

heh, so close

I'm up to at least 2 out of 3 living.

Guy looks at the 2 hats in front of him and says black if they're the same or red if they're different. The next guy (knowing if his hat is the same color or different color as the guy in front of him) can get his color right and the next guy can get his color right since he knows what color the guy before him had and whether or not it was the same or different.

Then they repeat that pattern in groups of 3.
 

merlocka

Platinum Member
Nov 24, 1999
2,832
0
0
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.
 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: JTsyo
Do they know if the guy behind them is executed or not?

They can hear everything going on behind them, so I suppose they'd hear it if the guy got executed.
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.
 

merlocka

Platinum Member
Nov 24, 1999
2,832
0
0
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Boy. U better hope your king doesn't lose any wars...

 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

I think you have the right idea, but you did a pretty poor job of explaining it. Try again and post a new puzzle :)
 

JTsyo

Lifer
Nov 18, 2007
12,035
1,134
126
Originally posted by: FDF12389
Originally posted by: JTsyo
Do they know if the guy behind them is executed or not?

How does that matter?

Figured it was one more piece of information they can use to communicate forward. Didn't come up with a system for it though.
 
Dec 26, 2007
11,782
2
76
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

I'm still alive... still alive
 

TuxDave

Lifer
Oct 8, 2002
10,571
3
71
Originally posted by: merlocka
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Boy. U better hope your king doesn't lose any wars...

.... waiting for a rewritten answer.
 

JTsyo

Lifer
Nov 18, 2007
12,035
1,134
126
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Only the last guy might die. He says odd or even for the 49 in front, now the next guy can see if it's odd or even in front of him so he can tell what his is. Everyone else just has to keep count of how many hats have gone behind them.

I would say it's 99% system since the last guy has 50/50 chance of being alive :p
 

FDF12389

Diamond Member
Sep 8, 2005
5,234
7
76
Originally posted by: JTsyo
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Only the last guy might die. He says odd or even for the 49 in front, now the next guy can see if it's odd or even in front of him so he can tell what his is. Everyone else just has to keep count of how many hats have gone behind them.

I would say it's 99% system since the last guy has 50/50 chance of being alive :p

I still don't get it.
 

coldmeat

Diamond Member
Jul 10, 2007
9,234
142
106
Originally posted by: FDF12389
Originally posted by: JTsyo
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Only the last guy might die. He says odd or even for the 49 in front, now the next guy can see if it's odd or even in front of him so he can tell what his is. Everyone else just has to keep count of how many hats have gone behind them.

I would say it's 99% system since the last guy has 50/50 chance of being alive :p

I still don't get it.

Lets say the guy at the back says there is an even number of black hats. When the next guy goes, if he counts an even number of black hats, then he knows his is red. If the 3rd guy goes and count an odd number of black hats, then he knows he is black.
 

puffff

Platinum Member
Jun 25, 2004
2,374
0
0
Originally posted by: Anubis
why does odd/even have anything to do with it, who said their needed to be an equal number of hats

that's what i was wondering... i read that the hats were assigned randomly, but nothing about 25 red hats and 25 black hats.
 

jonks

Lifer
Feb 7, 2005
13,918
20
81
Originally posted by: JTsyo
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Only the last guy might die. He says odd or even for the 49 in front, now the next guy can see if it's odd or even in front of him so he can tell what his is. Everyone else just has to keep count of how many hats have gone behind them.

I would say it's 99% system since the last guy has 50/50 chance of being alive :p

Ok, so he knows what his is, and then says his color regardless of passing on the message. What does the next guy do? Still not clear on this solution?

And what exactly are they describing as Odd or Even? The hats were placed randomly, it could be 42 red and 8 black. What are they describing as odd or even?
 

merlocka

Platinum Member
Nov 24, 1999
2,832
0
0
Originally posted by: TuxDave
Originally posted by: merlocka
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Boy. U better hope your king doesn't lose any wars...

.... waiting for a rewritten answer.

Jeez... would you like coffee and desert too?


BRRBRBBBR
1234567890

Black is the pre-decided upon "parity bit"

Guy0 looks ahead of him. There are 5 black hats. So he says black.

Guy9 hears him. He also knows if he's been shot or not. He looks ahead. He sees 4 black hats. He now knows how many black hats in front, and behind, and whether the total number of black hats is even or odd.

In this case, Guy0 was shot... poor bastage.

Guy9 counts 4 black in front of him. Since Guy0 said black (odd). He knows he must have on a black hat. So he says black.

Guy 8 heard it all too. Guy0's answer, whether guy0 was shot, and guy9's answer. He now knows how many black hats behind him (2), and how many in front (3), and that from Guy9 on the total was odd.

Lather rinse repeat.

 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: FDF12389
Originally posted by: JTsyo
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Only the last guy might die. He says odd or even for the 49 in front, now the next guy can see if it's odd or even in front of him so he can tell what his is. Everyone else just has to keep count of how many hats have gone behind them.

I would say it's 99% system since the last guy has 50/50 chance of being alive :p

I still don't get it.

hehe, ok, let me try:

Engineer #50, the first guy to answer (the one at the back of the line) looks at the 49 people in front of him and counts the number of black hats he sees. If this number is even, he says "black". If this number is odd, he says "red". This guy's chance of survival is 50/50.

Engineer #49 now looks in front of him and counts the number of black hats. There are 4 possibilities:

1. #50 had said "black" (even) and #49 still sees an even number of black hats in front of him. This means #49's hat MUST be red.
2. #50 had said "red" (odd) but #49 now sees an even number of black hats in front of him. This means #49's hat MUST be black.
3. #50 had said "black" (even) and #49 now sees an odd number of black hats in front of him. This means #49's hat MUST be black.
4. #50 had said "red" (odd) and #49 still sees an odd number of black hats in front of him. This means #49's hat MUST be red.

So, #49 can figure out the color of his own hat and yell it out. #48 also counts the number of black hats in front of him and repeats the procedure #49 did. The only difference is that he needs to "update" #50's answer. That is:

1. If #50 said "black" (even) and #49 said "black", there are now an odd number of black hats.
2. If #50 said "black" (even) and #49 said "red", there are now an even number of black hats.
3. If #50 said "red" (odd) and #49 said "black", there are now an even number of black hats.
4. If #50 said "red" (odd) and #49 said "red", there are now an odd number of black hats.

This procedure continues down the line: each engineer tracking whether there should be an even or odd number of black hats in front of him and answering accordingly.
 

jonks

Lifer
Feb 7, 2005
13,918
20
81
Originally posted by: merlocka
Originally posted by: TuxDave
Originally posted by: merlocka
Originally posted by: TuxDave
Originally posted by: merlocka
The last guy has a 50-50 to live.

But he counts the remaining hats. If it's even, he says red. If it's odd, he says black.

The second guy counts the hats. He knows what color he has. He then repeats the above.

98% survival rate.

This was in CS101, it's a parity check.

That makes no sense.

B <--- front of line
R
B
R
B
R <--- back of line

So let's say he's counting the number of black hats remaining and if it's odd he says black and if it's even he say red.

So guy #6 says Black (cuz he sees 3 black hats) and dies.
Guy #5 knows that he has a black hat but to follow the rules, he has to say red because he needs to pass on the information that there are an even number of blacks remaining. He dies too.
Guy #4 gets stuck in the same boat, dies too
....etc...

and soon everyone is dead.

Boy. U better hope your king doesn't lose any wars...

.... waiting for a rewritten answer.

Jeez... would you like coffee and desert too?


BRRBRBBBR
1234567890

Black is the pre-decided upon "parity bit"

Guy0 looks ahead of him. There are 5 black hats. So he says black.

Guy9 hears him. He also knows if he's been shot or not. He looks ahead. He sees 4 black hats. He now knows how many black hats in front, and behind, and whether the total number of black hats is even or odd.

In this case, Guy0 was shot... poor bastage.

Guy9 counts 4 black in front of him. Since Guy0 said black (odd). He knows he must have on a black hat. So he says black.

Guy 8 heard it all too. Guy0's answer, whether guy0 was shot, and guy9's answer. He now knows how many black hats behind him (2), and how many in front (3), and that from Guy9 on the total was odd.

Lather rinse repeat.

What if their throats are quietly slit? I didn't see anything about gun shots.
 

JTsyo

Lifer
Nov 18, 2007
12,035
1,134
126
Originally posted by: sirjonk


Ok, so he knows what his is, and then says his color regardless of passing on the message. What does the next guy do? Still not clear on this solution?

And what exactly are they describing as Odd or Even? The hats were placed randomly, it could be 42 red and 8 black. What are they describing as odd or even?


Ok, one assumption is that everyone can hear what the last guy said. Before hand they have to talk about it and decide which color he's going to call for even or odd. So say they pick black hats to call it on. SO the last guy tells them if there's an even or odd number of black hats. Since the next guy can see the hats in front of him, he can tell if his is black or not. Now the next guy knows what the last guy said and the color of the 49th guy and so on.