Riddle Thread

This is a discussion on Riddle Thread within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Oops, you are right. I didn't get it in the first place, so I wrote down this table:
Code:
BBB
...

Yet another riddle

Oops, you are right. I didn't get it in the first place, so I wrote down this table:

Code:

BBB
WBB
BBW B
BWB
BWW A
WBW B
WWB

The table lists all possible sticker combinations. If the 3-letter-combination is followed by another letter, then this letter denotes the dwarf that says the right answer. What I didn't see was the fact that every combination that is not answered by A or B ends with "black", so if A and B remain silent, C knows that his hat is black. Stupid me.

Bonus Riddle

If the dwarves are allowed to move, I have another solution:

The last dwarf (the one who can't see any other dwarf) moves forward one step. The next dwarf walks right next to him. Then comes the third, the fourth and so on. If a dwarf only sees hats of the same color, he goes to one side of the line. If a dwarf sees hats with different colors, then he goes to the spot right between the black and the white hat. All other dwarves then do the same. This way, the dwarves are separated into two groups, where each group has the same hat color. It's easily imaginable how every dwarf except the last one now knows his own hat color (without having seen the hats behind him), but it seems too messy to write it down.

This solution respects all constraints (as my first solution), but it may be considered cheating as the walking part communicates further information.

I'm pretty sure now that there is some sort of "cheating" involved here, because after the first dwarf did his guess (or hint), the next dwarf must stick to this proposal without being able to communicate further information just by saying "black" or "white" (if the optimal solution saves n-1 dwarfs).

Bonus Riddle

I think this is about parity. The dwarf who sees all hats (except his own) counts the black hats. If there's an even number, he says his own is black, otherwise he says it's white.
The next dwarf counts the number of black hats. If the number is even, and the previous dwarf said white, he knows that he's wearing a white hat, etc.
Every further dwarf now learns the color of all hats before him except the first, because all guesses except the first are right. So he can follow the same strategy as the second dwarf.

As an extra bonus, within a few generations the small dwarves have been bred out by trollish selection, and the dwarves will be on average tall enough to kill the troll.

50 dwarves in a cave

(or, Yet Another Redundant Riddle)

This is another dwarf/troll riddle. 50 dwarves are in a cave. As they want to leave, a group of trolls block the way. They pose the following challenge:
They'll let out a single dwarf at a time. The dwarf will be given the usual black or white hat, which he cannot see. Outside, the dwarf must take a position and then stay there.
When all dwarves are outside, their taken positions must be such that they're sorted, i.e. a single straight line can divide the white-hats from the black-hats. Otherwise, they all get eaten.

Communication of any sort is strictly forbidden. The trolls have brought a mind-reader and will know about any cheating attempt. There's also enough trolls to prevent any escape attempt by those outside the cave.

Ok, for those who may have been following but haven't quite figured out the one I've posted, here's a solution. It's a simple error correcting code.

The dwarves agree that the last dwarf will count the number of white hats and yell out "white" if there is an even number, and "black" if there is an odd number. The next dwarf can then count the hats in front of him, and know his hat colour as it will balance out the number of white hats as being either even or odd. The next dwarf can count the hats in front of him, and has heard the colour of the previous dwarf, and can again determine his hat colour to balance partiy. It continues with each dwarf seeing the hats in front of him, and having heard the hat colours before him.

oh hey, I didn't even see Corned Bee's solution to the one I posted. nice one!

I figured out Corned Bee's Riddle. I kept trying to think of it geometrically, but it's much simpler than that. You just always insert yourself in the "middle" of the black and white hats in a line. that way you'll be part of either group. If there's only one colour you can be at an arbitrary end of the line.