10 little dwarves

Parity: Dwarves agree that black = 1 and white = 0. First dwarf adds up all the hats he sees mod 2 and calls that out. The rest of the dwarves need to rememeber this. Each dwarf adds up the hats he sees mod 2 and if it's the same, considers his hat white, if it's not the same parity, then he considers his hat black.

After that each dwarf in turn calls out his presumption of hat color, except that the listening dwarves must change their guess each time someone before them calls "black" (after the first dwarf). That way they only have to add up the hats once, and do not need to remember each call, only to change their color when "black" is called.

All dwarves but the first are guarenteed to survive.


This video from Khan academy might be of use:

https://www.youtube.com/watch?v=K4pocYXOmTQ


Solution 1: If the last shout the first color and the second last the second color, at least for sure first five in row will survive. Solution 2: Since there is no obligation on the way they answer, they can agree on this; If I say the color only, "black" or "white" it means the one in front of me is white If I say the color in a sentence, "It's black" or "It should be white", then it means the one in front of me is black.

By following these rules 9 will survive and there is 50% chance for 1.

Example: The last says "black" means the next is white. so the next will say "white" if in front is white and he says "it's white" if the next is black.