# HATS EXERCISES

## A warm up

There are `n`

gnomes in the village of Goldor-Bom. One days the gnomes
are visited by a wizard, and the gnomes agree to play the following
game with her.

Next morning the gnomes shall go to the main street where the gnomes will have to stand in a line formation. Then the wizard will put hats of either black or white color on the gnomes. Each gnome will be able to see the hat colours only of those gnomes who are in front of him. Then the gnomes will be asked, in accordance with the line order: “What is the colour of the hat that you are wearing?”

If a gnome answers correctly, he shall get a candy bar. What common strategy the gnomes should follow to obtain the maximum amount of candy?

## The infinite case

Suppose there are infinite, but countable number of gnomes in the village. The wizard proposes the same task.

Can the gnomes agree on a common strategy that will allow all but finite number of them to receive candy?