# 1 to 27 - Guess my number

Each of four people wear a hat with a distinct positive integer $<28$. Everyone can see everyone’s number except his own. At 12:00 pm everyone can say something: either “Red” or “Yellow” or nothing. After 12:00 everyone must know his own number. How can they achieve this?

Source: Brilliant

• HINT: $27=3^3$. – Bram28 Apr 7 '18 at 13:22
• Are they able to say red, yellow or none more than once? – John Douma Apr 7 '18 at 13:47
• No, only one word is allowed! – Leo Gardner Apr 7 '18 at 13:51
• Can they talk with each other before they start this test or something??? – Nimantha Apr 7 '18 at 14:09
• @user120527: Each participant sees three of the four numbers, so they can combine that information with the spoken data to determine one of $24$ possibilities for their own number. – hardmath Apr 7 '18 at 14:10

Let's assume they are around a round table. For each participant X, let $A$ be the guy to his left, $B$ the guy in front, $C$ to his right. Let's write the numbers on the hats in basis $3$: $$n_X=x_2*9+x_1*3+x_0.$$ So $X$ says the number $a_0+b_1+c_2 \pmod 3$ (red=0, yellow=1, nothing=2).
• He hears from $A$ the number $b_0+c_1+x_2 \pmod 3$. Since he already knows $b_0,c_1$, that tells him $x_2$.
• He hears from $B$ the number $c_0+x_1+a_2 \pmod 3$. Since he already knows $c_0,a_2$, that tells him $x_1$.
• He hears from $C$ the number $x_0+a_1+b_2 \pmod 3$. Since he already knows $a_1,b_2$, that tells him $x_0$.