A Christmas puzzle: $n$ children in a row identifying the colors of their hats 
$n$ children are placed in a row from north to south such that all of them look at north; i.e., every child does only see the children before him. After being placed in the row, they aren't allow to move or communicate in any form possible.
Every child will have a random bobble hat marked with a color in $0, \dots, k$, with $k \leq n - 1$ on his head. Noone knows which color its hat has, and noone is allowed to look after.
After all children have their hats, they shall say which color his hat has. They are only allowed to say "color $i$". If more than one child will say the wrong color, no one gets a present.
What is the winning strategy for the children?

I think it could have something to do with the Chinese Remainder Theorem. Otherwise, I can only imagine to speak rhythmically to encode the number of combination, but that seems not to be intended.

The child who sees all the others starts and says the sum of all colors he/she sees, modulo $n.$ Then the second one can subtract the sum of the colors he/she sees from that number, does the modulo $n$ calculation and knows their own color and says it. The third child subtracts the sum of the colors he/she sees and the color of the second child from the first said number and so on. Continuing this way, everyone but the first child will say the correct number.
