# Multi-variable hat guessing

Here is a variation of the hat-guessing logicians problem.

100 logicians are given hats. They know that:

1. All the hats are either black or white
2. Each hat may or may not have green stripes on it
3. Each hat may or may not have a pompom on top
4. At least one of them will be wearing a black hat with green stripes and a pompom

As usual, each logician can see everyone else's hat but not their own. The logicians may discuss strategy before they are given hats, but may not talk to each other afterwards. Once every five minutes after they've been given hats, any logicians who want have a chance to state what they believe their hats to be like (black or white, striped or not, with or without a pompom.) If all the logicians eventually figure out what their hats are like, they win. But if any of them are ever wrong about their hats, they all lose. What strategy should they use to all figure out their hat type in the shortest amount of time?

I do have a solution to this, but I don't know if it's the optimal one.

Also, bonus if anyone can come up with a strategy that works even without the logicians knowing 4).

Well, the first step will have to be

with an extra modification to encode information in the timing of the guess.

To include information in the guess timing, the logician calculates

the parity of the number of hats they see, and use it to construct a binary number between 000 (0 in decimal) and 111 (7 in decimal):
* leftmost bit: 1 if the number of black hats they see is odd
* middle bit: 1 if the number of striped hats they see is odd
* rightmost bit: 1 if the number of pompom hats they see is odd.

Then, whenever a logician knows their own hat colour, they

delay their answer by the amount indicated by the number they constructed,

which is how the information gets conveyed.

Once a guess with this information has been taken, every logician can instantly deduce their own hat type (there's only one hat type they can have that makes all the parities match), so we only need to ensure the first guess is correct:

* if there's only one logician with a "111" hat (black hat with green stripes and a pompom), they'll answer during the first 8 "ticks", because they see no other such hats.
* if there are two "111" hats, both of them will answer at the same time during the next 8 ticks. (Both know the other guy saw at exactly one 111 hat, which must have been on their own head. Also, since they see each others' hats, which are the same, their timing will also match.)
* if there are three "111" hats, all three will answer at the same time during ticks 17-24
* and so on.

This is slow, because the first guess will only happen after

1-8 ticks (5-40 minutes) depending on the parities, plus an extra 8 ticks (40 minutes) for each black-striped-pompom hat beyond the first one,

but I couldn't come up with a more efficient approach off the top of my head. (Hehe.)

EDIT: Here's what I believe to be the quickest possible guaranteed-win strategy:

Timing:

• Tick - how many 5-minute periods have passed

Situation:

• BSP Hats - total number of black hats with stripes and pompoms
• B Parity - 1 if the number of black hats seen by the guesser(s) is odd
• S Parity - 1 if the number of striped hats seen by the guesser(s) is odd
• P Parity - 1 if the number of pompom hats seen by the guesser(s) is odd

Who should guess:

• Guesser 1 - Counting from John leftwards, the 1st person that has a BSP hat
• Guesser 2 - Counting from John leftwards, the 2nd person that has a BSP hat
• Guesser 3 - Counting from John leftwards, the 3rd person that has a BSP hat
• Guesser 4 - Counting from John leftwards, the 4th person that has a BSP hat

(Decide beforehand, who is "John", and arrange the logicians to a circle before the game starts.)

On any tick, the dedicated guessers know which guesser they are. (This is the important bit that allows a solution to exist in the first place.)

From the guesser information, and the tick number, everyone can work out which situation they are in, and from the situation, everyone can deduce their own hat type.

Since this method enumerates every possible case, it will always work. It is also optimal in the sense that apart from correct guesses, no other information can be passed, and this scheme uses all the possible guess patterns to mean something different. (I'm assuming that a logician isn't allowed to "cheat the system" by guessing correctly more than once, which could shave off another couple of rounds.)

With this method, the logicians will win no later than on round N+11, where N is the total number of the special Black-Stripes-Pompom hats.

• Nice! This is a better solution than the one I had in mind, which was rot 13(rnpu punenpgrevfgvp (oynpx, fgevcrq, cbzcbz) vf nffvtarq n cbjre bs 2 (1,2,4). Rnpu ybtvpvna pbhagf gur ahzore bs ungf gurl frr jvgu rnpu punenpgrevfgvp naq zhygvcyvrf gurz ol gurve nffvtarq ahzoref, gura nqqf gur erfhygvat ahzoref gbtrgure naq thrffrf ba gung ebhaq vs ab bar unf lrg thrffrq.)
– Ilak
Jul 25, 2020 at 20:19
• I wonder whether the delay can induce confusion as to who are the black-green-pompon logicians. The black-green-pompon logicians know exactly when to respond, but the non-black-green-pompon logicians don't know how long not to respond. Jul 26, 2020 at 14:42
• @FlorianF on every tick, the "no-one guesses" option rules out the cases listed for that tick. Since every logician knows the strategy (they might even have it printed out for reference), they know, for example, that the "only one BSP hat" case is not fully ruled out until tick eight is a no-answer.
– Bass
Jul 26, 2020 at 15:38