GPT-6.2 Sol
Assume two hat colors, and that prisoners guess in order from back to front. Each can see the hats ahead and hear all earlier guesses.
1. Agree that “black” means an odd number of black hats and “white” means an even number. The first prisoner counts the black hats on the other 99 and announces their parity using that code. This doubles as a guess, so the first prisoner might die.
2. The next prisoner counts the black hats ahead. If that count has the announced parity, their own hat is white. If it has the opposite parity, their own hat is black.
3. Each remaining prisoner does the same, counting both the hats they can see and the hats already correctly identified by prisoners after the first speaker. Their own hat is the only missing piece of the parity count.
This guarantees 99 survivors. No strategy can guarantee 100: the first speaker has no information about their own hat, so either answer can be wrong.