bison

AI Arena · 2026-11-19

Prisoners and hats logic puzzle: GPT vs Claude vs Gemini vs Grok

Prompt: Solve the classic 100 prisoners and hats puzzle: each sees others' hat colors, guesses their own. What strategy saves the most prisoners, and why does it work? Explain step by step.

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.

Claude Sonnet 5.5

Setup (classic version): 100 prisoners stand in a line, each wearing a black or white hat. Each sees only the hats in front of them. Starting from the back, each guesses their own hat color aloud, and everyone hears the guesses.

Strategy: agree beforehand that black = 1 and white = 0, and that the first prisoner announces parity.

Step 1: The last prisoner (who sees 99 hats) counts the black hats ahead. If the count is even, he says "black"; if odd, he says "white." This is a parity signal, not a real guess. He has a 50% chance of surviving.

Step 2: The next prisoner hears the signal and sees the 98 hats ahead. If the parity of black hats he sees matches the signal, his own hat must be white. If it differs, his hat is black. He answers correctly.

Step 3: Each following prisoner keeps track of the signal and all correct answers heard behind him. He compares the parity of the hats he sees ahead with the parity the first prisoner announced, adjusted for the hats already revealed behind. The difference reveals his own color.

Result: prisoners 2 through 100 are always saved, and the first has a 50% chance, so at least 99 survive guaranteed, and 99.5 on average.

Why it works: one bit of information, parity, is enough to determine each hat color. Each prisoner knows the total parity, sees everything ahead, and has heard everything behind, so only his own hat remains unknown.

Gemini 4 Argon

In this puzzle, 100 prisoners stand in a line wearing black or white hats. Each sees the hats in front of them and must guess their own hat color, starting from the back. A parity strategy guarantees saving 99 prisoners, with the first having a 50% chance.

Step 1: Beforehand, prisoners agree that "black" represents the parity of black hats. Saying "black" means an odd number of black hats is visible; "white" means an even number.

Step 2: The 100th prisoner at the back sees 99 hats. He counts the black hats and announces the corresponding color. He has a 50% chance of survival, as his hat color is random.

Step 3: The 99th prisoner remembers this parity and counts the black hats among the 98 in front of him. If the parity changed, his own hat must be black. If it stayed the same, his hat is white. He states his color and survives.

Step 4: Each subsequent prisoner tracks the previous black guesses to deduce their own hat color using the original parity.

Why it works: The first prisoner transmits one bit of information (odd or even) to everyone. Since each prisoner sees all future hats and hears all past answers, they can solve for the only unknown variable: their own hat.

Grok 4.7

Line them up so the rear prisoner sees the other 99. Agree black is 1 and white is 0. He calls the parity of black hats he sees, saying "black" for odd and "white" for even. That call matches his own hat only by chance, so he has a 50% chance.

Each prisoner ahead hears that parity and every later guess. He totals the hats he sees; the difference from the announced parity is his color. After he states it, the others subtract that hat and repeat. All 99 in front are saved for sure.

It works because one shared parity bit lets each prisoner solve for his own hat once the hats behind him are known.

What stood out

All four give the correct parity strategy: 99 certain survivors, with the first prisoner at 50%. GPT and Claude explain best, with GPT justifying the 99 cap and Claude giving the most detail, while Gemini and Grok are thinner.

Best pick, by need

Answers were generated on 2026-11-19 with default settings and one attempt each. Results vary from run to run.

Test your own prompt on all four.

Bison sends one prompt to up to six models and shows the answers side by side. Free plan, no card.

Try Bison free

More matchups