A Hat Riddle

If you like hat riddles, you'll love this.

Before we dive in, this is a classic hat riddle I created. If you are unfamiliar with hat riddles or would like to try more, the hat puzzles on this website are fantastic.

Riddle: Suppose we have 5 people in a line and 8 hats: 4 black and 4 white. 5 of the 8 hats are randomly chosen and placed on the people in line. Each person can only see the hats of everyone in front of them in line.

In this game, only one person guesses the color of their hat. If they guess correctly, everyone wins. If not, everyone loses. Any person can be the one to guess, and the guesser has one minute to guess. No communication, neither verbal or nonverbal, is allowed.

Propose a strategy the 5 people can come up with that guarantees victory.

Hint 1: Everyone can keep track of the time.
Hint 2: A similar riddle: www.popularmechanics.com/science/math/a24100/riddle-of-the-week-5

Solution:

For simplicity, I'll refer to people by their position in line (starting with 1, ending with 5). Everyone gets a turn of 15 seconds. First, 5 can announce their color by process of elimination if everyone in front of them, i.e. 1-4, all have the same color of hat.

If 5 doesn't guess within the first 15 seconds of the game, then 4 knows someone in front of 5 doesn't have the same color hat on. If everyone in front of 4 is wearing the same color hat, then 4 knows they should say the opposite color. If 4 doesn't say anything within the next 15 seconds, then 3 knows that someone in 1-3 has a different-colored hat on. If 3 sees 1-2 have the same color hat, then 3 should pick the opposite color. Finally, if 15 seconds are left over and nobody has announced their color, then 2 should announce the opposite color of 1's hat.