The three-colour hat guessing game on the cycle graphs

We study a cooperative game in which each member of a team of $N$ players, wearing coloured hats and situated at the vertices of a cycle graph $C_N$, is guessing their own hat colour merely on the basis of observing the hats worn by their two neighbours without exchanging the information. Each hat can have one of three colours. A predetermined guessing strategy is winning if it guarantees at least one correct individual guess for every assignment of colours. We prove that a winning strategy exists if and only if $N$ is divisible by $3$ or $N=4$. This problem represents an example of a relational system using incomplete information about an unpredictable situation, where at least one participant has to act properly.


Introduction
N ladies wearing white hats are sitting around the table and discussing a tricky task which is going to be presented to them by the Wizard. They know he will suddenly paint each hat one of three colours (green, orange or purple) in an unpredictable way and then ask each of them to independently guess her own hat colour. The light is so dim that everyone will only see the hat colours of her two neighbours. If at least one of the ladies guesses right, they will all win; if they all guess wrong, they will lose; and they want to be absolutely certain of winning. However, can they devise a winning strategy before they invite the Wizard?
The answer, depending on the number N, is presented in this paper. Problems of this kind have become popular in recent years both as mathematical puzzlers (see [2], [3]) and research subjects. Basic results so far concerned two colours (instead of three), or unrestricted visibility (a complete graph), or probabilistic variants (the expected number of the correct guesses): see [1], [4], [5], [6], [8] and overviews in [7] and [9]. The round-table problem described above has until now remained open for all N > 5. right). It will be technically convenient to regard them either as pairwise disjoint (0 ≤ k < N), or simply as V k = Z 3 . A cyclic notation will also be used: An individual guessing strategy of Player k is represented by a function which may simply be regarded as a function (i, If there exists such a sequence, f is a losing strategy.

Hat games on graphs
In a more general setting an arbitrary 'visibility' pattern can be assumed. For a broader exposition, see [7] ald [9]. The directed 'visibility graph' Γ has N vertices corresponding to the players, and edges AB ∈ E(Γ) = E wherever player A is seen by player B. For each vertex v ∈ V (Γ) = V a nonempty set of 'colours' V v is known to all. For each 'assignment of colours', i.e., a selector g : each player u ∈ V tries to guess g(u) by using a function as an individual strategy. The combined, or collective, strategy is the collection f = {f u : u ∈ V }. The game is thus played against an opponent assigning the colours (the Wizard, the Demon, Chance, etc., in a fantasy world). In this paper, the notion of winning or losing refers to the cooperative players. The strategy effectiveness depends only on the numbers of possible colours, i.e., the function h given by h(v) = |V v |. Let X h (f, g) denote the number of correct guesses. The deterministic minimax approach defines the value of this game as This paper concerns the minimal condition µ(h) > 0 where f is a winning strategy if min g X h (f, g) > 0.
J.Grytczuk has conjectured that a winning strategy exists provided 3 Examples with N < 5 The game on C 2 In the simplest puzzle (outside our main problem, though) there are just two players and two possible hat colours. In this situation one person should guess that their hats have the same colour and the other person sholud guess the opposite. If one interpretes the colours as elements A, B ∈ Z 2 , the effect can be written as an alternative: Next, suppose Player 1 hat can still have two colours, but Player 2 hat can have three colours. Then there are six possible colour assignments. With any strategy, Player 1 guesses right for three assignments, Player 2 for two. Since the number of assignments is 6 > 3 + 2, they can both be wrong and they have no winning strategy. (In the above cases, the players might as well guess the other person's colour while knowing their own.) An algebraic strategy for C 3 If A, B, C ∈ Z 3 represent the appearances of hats, then a winning strategy can be based, for instance, on the alternative: An algebraic strategy for C 4 Let variables A, B, C, D ∈ Z 3 represent elements of the sets V 1 , V 2 , V 3 , V 4 , respectively. Then a winning strategy f can be based on the following alternative: To verify (1), let us suppose the first and third equalities are false. In Z 3 this implies If the signs above are opposite, we add the equations to get 2B = A+C, equivalent to the second equation of (1). If the signs are the same, we subtract the equations to get 2D = A − C, equivalent to the last equation of (1). Thus indeed, strategy f wins.

The main result
Let us observe the following (inconvenient, as it turns out) property of the last two examples. For any b ∈ V m and c ∈ V m+1 there is exactly one d ∈ V m+2 satisfying f m+1 (b, d) = c and exactly one a ∈ V m−1 satisfying f m (a, c) = b. However, winning strategies with this property are not possible for N > 4 (see Section 4). Our method will thus produce another kind of strategy for some N-gons whenever possible, while demonstrating the losing case for all the rest. The main result of this paper is: Theorem 1 In the three-colour hat guessing game on the cycle of length N a winning strategy exists if and only if N is divisible by three or N = 4.

Proof of the main result
An interplay of various relatively simple local and global combinatorial methods will be used.

Admissible paths in the enlarged graph
Let us introduce a larger graph G = G N (which we will also denote 3 * C N ) whose Remark An analogous construction can applied to any visibility graph Γ and any height function h : V (Γ) → N \ {0} (whose values are the numbers of possible colours). The resulting graph, which may be denoted G = * Γ, has

Now let us consider a (composite) strategy f .
Definition 1 Let J be any set of consecutive integers. A path (s k ) k∈J in the graph G will be called f -admissible (or simply admissible, when f is fixed) if ✷ Thus, a path is admissible if and only if all its 2-edge segments (i.e., sub-paths of length 2) are admissible. It is clear that strategy f is winning if and only if the graph G contains no f -admissible path (of infinite length) which is periodic and has period N, or equivalently, no f -admissible path of length N + 1 whose last edge coincides with the first. However, the definition does not direcly settle the question of whether any periodic admissible path exists, and if it does, whether it can have period N (or at least less than 9N).
The set of all the f -admissible paths (of all lengths) will be denoted A(f ). The set of all the edges between V k and V k+1 will be denoted by Definition 2 Let f be a fixed strategy. For any edge bc ∈ E k,k+1 , define i.e., the number of the immediate admissible continuations of bc to the right, and i.e., the number of the analogous continuations to the left. ✷ Hence, in general, we have ℓ + (bc), ℓ − (bc) ∈ {0, 1, 2, 3}.
Lemma 2 Consider a fixed strategy f .
(a) The average value of ℓ − (resp. ℓ + ) over any three right-adjacent (resp. leftadjacent) edges of G equals 2. That is, for any vertex b ∈ V k we have ℓ + (bc) = 6 (b) If two edges of G have the same left (resp. right) endpoint then one of them has at least two admissible immediate continuations to the right (resp. left). That is, for any vertex b ∈ V k and any two distinct vertices the analogous fact holds for passages to the left.
then f is a losing strategy.
(d) If f is a winning strategy, then for every edge β ∈ E(G) we have , then f is losing by (c) applied to the single edge β. However, (a) implies that the average value of ℓ(γ) over γ ∈ E k,k+1 equals 4. Hence, if there was an edge α ∈ E k,k+1 with ℓ(α) < 4, there would also be an edge β ∈ E k,k+1 with ℓ(β) > 4, the case already excluded.

The three categories of edges
Let us assume that strategy f satisfies Then all the edges γ ∈ E(G) can be divided into three categories: Figure 1: Closing the path of Lemma 2 (c).  • If ℓ − (γ) = 3 and ℓ + (γ) = 1, let us paint γ yellow and direct it right.
The three patterns can thus be shown as in Figure 2.
Definition 3 Any strategy f satisfying (3) will be called balanced or colourable. ✷ By Lemma 2(d), every winning strategy is colourable. However, not all balanced strategies will be winning. The sets of all the yellow, red, and blue edges in E(G) (or in E k,k+1 ) will be denoted E + , E − , and E 0 (or E + k,k+1 , E − k,k+1 , and E 0 k,k+1 ), respectively.
Lemma 3 If strategy f is colourable, then: (a) For each k, there are equal numbers of yellow and red edges in the set E k,k+1 (i.e., |E + k,k+1 | = |E − k,k+1 |). (c) If f is a winning strategy and N ≥ 4, then every directed edge is admissibly continued in its direction by an edge of the same direction. That is, if β ∈ E k,k+1 is yellow, γ ∈ E k+1,k+2 and the path βγ is f -admissible, then γ is also yellow. Figure 3: An example of the typical configuration at the head or tail of any directed edge.
(d) If f is a winning strategy and N ≥ 4, then every directed edge is a continuation of three edges of three different colours. That is, if β = bc ∈ E k,k+1 is yellow, then among the three edges ab with a ∈ V k−1 one is yellow, one is red, and one is blue. Analogously, if β = bc is red, then among the edges cd ∈ E k+2 one is in E + , another in E − , and the third in E 0 .
(e) If f is a winning strategy and N ≥ 4, then any periodic f -admissible path has one colour. Conversely (under the same assumption), any path of a fixed direction (red or yellow) is admissible, and an undirected path (blue) is admissible provided that all its vertices are incident to some directed edges.
The terms equal to 1 and 3 in the first sum correspond to the terms equal to 3 and 1, respectively, in the second. (b): This follows from Lemma 2(a)(d), since the number 6 can be expressed as an unordered sum of three terms equal to 1, 2 or 3 in just two ways: 1 + 2 + 3 and 2 + 2 + 2.
(d): Let β = bc ∈ E k,k+1 be yellow. By (b), some edge γ = bc ′ ∈ E k,k+1 must be red. Then, by (c), the left continuation of γ into E k−1,k is also red, showing that not all edges ab ∈ E k−1,k are blue. By (b), these edges must be of three colours.
(e): Consider any path containing a yellow (resp. red) edge β. By (c) and the definition of colouring, the edge β has a unique forward (resp. backward) admissible continuation, consisting of edges of the same direction. This proves that every periodic admissible path must have one direction or be undirected. Conversely, any directed path is admissible by (c).
Finally, consider a blue path abc (of length 2) with vertex b incident to some directed edge. We may suppose an edge bc ′ is directed. By (b) and (c), there is some left-directed edge bc ′′ uniquely continued by another edge a ′ b ∈ E − ∋ ab. Since abc ′′ is not f -admissible and ab is blue, both remaining right continuations of ab must be f -admissible, including abc.
Alternative arguments (b) implies (a), since there must be equal numbers (0 or 1) of red and yellow edges left-incident to every vertex of G. Another way of proving (d) is using (c) to continue β to the right with yellow edges until the last one points to the beginning of another, which must be β (the first one), as two yellow edges cannot be (right-)incident, by (b).

The characteristic number of a winning strategy
Corollary 4 Let f be a winning strategy and N ≥ 4.
(a) Every directed edge β ∈ E k,k+1 meets exactly two edges of G having the same direction. Moreover, one of them is an α ∈ E k−1,k and the other is a γ ∈ E k+1,k+2 , and the path αβγ is f -admissible.
(b) There exists an integer χ(f ) ∈ {0, 1, 2, 3} such that for all values of k, the set E k,k+1 contains exactly χ(f ) yellow edges and the same number of red edges.
Proof. (a): Consider an edge β ∈ E + k,k+1 . By Lemma 3(b), β cannot be coincident to another element of E + k,k+1 . By Lemma 3(d), there is a unique edge α ∈ E + k−1,k meeting β. By Lemma 3(c)(b), there is a unique edge γ ∈ E + k+1,k+2 adjacent to β. (Again, the case of E − is symmetric.) (b): By (a), the set E + k,k+1 has at most 3 elements (as including no coincidences) and there is a one-to-one correspondence between the elements of E + k,k+1 and E + k+1,k+2 for every k (namely, α ↔ β ↔ γ) Now it is enough to use Lemma 3(a) and the fact that the cyclic graph C N is connected.

Definition 4
The number Corollary 4(b)) will be called the characteristic number of the winning strategy f . ✷ The case χ(f ) = 1 can be excluded outright, since it would imply the existence of an f -admissible N-periodic paths of both directions (red and yellow). Now only three cases remain: χ(f ) = 0, 2, and 3.

The case χ(f ) = 0
Here we additionally suppose that N ≥ 5 (the cases of N = 3, 4 being already settled).
In the case of χ(f ) = 0 all the edges of G are blue. That was possible for N = 3 and N = 4 as shown in Section 3. But supposing N ≥ 5 we are going to prove that f would in fact be a losing strategy, implying χ(f ) = 0 for N > 4.
Take any edge ab of graph G N . It has, in particular, 32 different f -admissible extensions of length N + 1, by N − 3 edges to the left and 3 edges to the right, of the form a ij a j u 1 .
for i, j, p, q, r ∈ {1, 2}, where the choice of vertices u 1 . . . , u N −4 is fixed. Observe that, while there are exactly 4 edges of the form a ij a j and b p b pq alike, there may be either 2 or 3 vertices b pq (and a ij alike).
First, suppose vertex b pq assumes three different values. Then there are at least six edges b pq b pqr , while the number of the edges a ij a j is four, making the path close as 6 + 4 > 9. Next, suppose there are just two different vertices b pq . We can make index q point to these vertices, so that b 0q = b 1q for q = 0, 1. Since the a ij and b pq are both in a 3-element set V m , one can now fix i, j, q so that a ij = b 0q = b 1q . Then, one of two paths b p b pq a j (p = 0, 1) must be admissible since ℓ − (b pq a j ) = 2 and b p takes 2 values. Thus, the path (4) acquires a closure with no use of vertex b pqr . (But in fact, a j = b pqr for some r.) Corollary 5 For N > 4, every winning strategy f has χ(f ) = 0. 5 The case χ(f ) = 3 By Corollary 4, the yellow edges of graph G are arranged as follows: where {u 1 (k), u 2 (k), u 3 (k)} = V k for all k and σ : {1, 2, 3} → {1, 2, 3} is a permutation.
(If σ had a fixed point, then a yellow cycle of period N would defeat strategy f . Hence, σ must be a rotation: σ(i) ≡ i ± 1 (mod 3) for i = 1, 2, 3. This observation will be used later to construct winning strategies.) Now let us locate the other colours. By Corollary 4, the set E 1,2 contains three disjoint red edges. Thus, we may assume (the other possibility being symmetric: u 1 u 2 , u 2 u 3 , u 3 u 1 ). Considering the set E 0,1 (to the left of E 1,2 ) we see that u 3 (0)u 2 (1) is red. Indeed, since u 3 (0)u 3 (1) ∈ E + , we have u 3 (0)u 3 (1)u 1 (2) ∈ A(f ), so u 3 (0)u 2 (1)u 1 (2) ∈ A(f ), implying that u 3 (0)u 2 (1) must be the left-directed left continuation of u 2 (1)u 1 (2) ∈ E − (by Lemma 3(c)). It follows that the edges in E − 0,1 have the same arrangement as in E − 1,2 . Similarly, the sets E − k,k+1 and E − k+1,k+2 have the same arrangement for all k = 0, . . . , N − 2, so we may assume that All the remaining edges of G must be blue (by Lemma 3(b)). Here, by Lemma 3(e), the periodic f -admissible paths are precisely the periodic ones of a fixed colour. Now consider all three one-colour paths of length N, starting at vertex u 1 (0) and going to the right (for the red one, this means going back). If N is divisible by 3, they all end at u σ(1) (0). But if N is not divisible by 3, they end at three distinct vertices of V N , one of which must be v 1 (0). That makes one of the paths close to defeat the strategy, which is a contradiction. A significant part of the situation for N = 5 is illustrated in the diagram.  Figure 4: Part of a typical strategy of characteristic 3 on C 5

Winning for 3|N
If N is a multiple of 3 and strategy f is colourable in the pattern just considered, then any one-colour path starting at u i (0) passes through u i (N) = u i (0) and goes three times around the graph G N , ending with period 3N = N. Moreover, the considered colour arrangement is always (for every N) given by some colourable strategy, defined in the following way. Let where σ is some fixed-point-free permutation, and using the convention: f k (i, j) in row i, column j. The definition is consistent since f k is rotation-invariant, i.e., f k (σ(i), σ(j)) = σ(f k (i, j)), which can be checked directly. (In fact, the strategies f k are uniquely determined by this rotation-invariant colouring, hence they must themselves be σ-invariant).
With this strategy, every directed edge is followed by an edge of the same direction, as in Lemma 3(c)). Thus, any admissible periodic path has one colour, as in Lemma 3(e). Since no admissible path has period N, the strategy is winning. Remark. The situation for χ(f ) = 3 can be visualised on a torus obtained by rotating a triangle which at the same time makes 1/3 of a full turn in its own plane. This situation can also be viewed using a covering of graph 3 * C N by the graph 3 * C ∞ , where C ∞ has edges between all pairs of consecutive integers and is the universal covering of C N . 6 The case χ(f ) = 2 Corollary 4 implies the following arrangement of all the yellow edges and some blue edges of graph G: which has period 8 as u 1 (1) = u 1 (5). This shows that f is a winning strategy for N = 4. If, however, 2|N and N ≥ 6, then there exists the following admissible blue path of period N: . . . 3313(31)(32)(31)(32) . . . (3j) . . .
(where j ∈ {1, 2} and j ≡ N/2 (mod 2)). Consequently, the strategy f is loosing for N > 4. The situation for N = 8 is illustrated in the diagram.

The solution for χ(f ) = 2
Corollary 7 A winning strategy f with χ(f ) = 2 exists only for N = 4 (and is unique up to isomorphism).
Remark. The above situation for 2|N can be visualised as a Möbious band with the yellow cycle on the boundary and the red cycle inside, completed with a separate blue cycle which is not admissible. The edges can be drawn on a Klein bottle arising from this construction. As before, this is equivalent to using an appropriate covering of graph 3 * C N by the graph 3 * C ∞ .
Thus we have proved Theorem 1.

Corollaries
The number of 3 colours turns out to be effectively maximal for the cycle graphs.
Proof. If f were a winning strategy for this game, then it would also be winning for any of its 3-colour restrictions. It follows that choosing any k ∈ {1, 2, 3, 4} and changing any values f 1 (i, j) = k into any values f 1 (i, j) = k would result in a winning strategy for the 3-colour game. By Corollary 6, such a strategy is unique up to permutations of colours. Now, f 1 assumes some values, so for instance, we have f 1 (i, j) = 4 for some pair(s) (i, j). But the form (5) of the individual strategy shows that f 1 must assume each value three times. Some arbitrary choice of f (i, j) = 4 could always change that, contrary to the fact that f should remain a winning strategy.
If N is not divisible by 3, at least a strategy with a high probability of winning can be found.

Corollary 9
In the three-colour game on any cycle C N (3 |N) there exists a strategy for which the probability of winning is ≥ 1 − 3 −N +1 .
Proof. This follows from the fact that the strategy described in Section 5 has at most three admissible N-periodic paths.