Source: TSTST-2023-P3
Category: Existence and Construction

Problem:
Find all positive integers $n$ for which it is possible to color some cells of an infinite grid of unit squares red, such that each rectangle consisting of exactly $n$ cells (and whose edges lie along the lines of the grid) contains an odd number of red cells.

Solution:
We claim that this is possible for all positive integers $n$. Call a positive integer for which such a coloring is possible *good*. To show that all positive integers $n$ are good, we prove the following two statements: 
(i) If $n$ is good and $p$ is an odd prime, then $pn$ is good.
(ii) For every integer $k \ge 0$, the number $n=2^k$ is good. 

Together, (i) and (ii) imply that all positive integers are good by prime factorization.

**Proof of (i):**
We simply observe that if every rectangle consisting of $n$ cells contains an odd number of red cells, then so must every rectangle consisting of $pn$ cells. Indeed, because $p$ is prime, a rectangle consisting of $pn$ cells must have a dimension (length or width) divisible by $p$ and can thus be subdivided into $p$ disjoint rectangles consisting of $n$ cells. Since the sum of $p$ odd numbers is odd (as $p$ is an odd prime), every coloring that works for $n$ automatically also works for $pn$.

**Proof of (ii):**
Observe that rectangles with $n=2^k$ cells have $k+1$ possible shapes: $2^m \times 2^{k-m}$ for $0\le m \le k$. For each of these $k+1$ shapes, there exists a coloring with two properties:  

1. Every rectangle with $n$ cells and shape $2^m \times 2^{k-m}$ contains an odd number of red cells.  
2. Every rectangle with $n$ cells and a different shape contains an even number of red cells.  

This can be achieved as follows: assuming the cells are labeled with coordinates $(x, y) \in \mathbb{Z}^2$, color a cell red if $x \equiv 0 \pmod{2^m}$ and $y \equiv 0 \pmod{2^{k-m}}$. 

Finally, given these $k+1$ colorings, we can add them up modulo $2$; that is, a cell will be colored red in the final combined coloring if and only if it is red in an odd number of these $k+1$ individual colorings. For any rectangle of $n=2^k$ cells, its shape matches exactly one of the $k+1$ shapes. By the two properties, it contains an odd number of red cells in the corresponding coloring and an even number of red cells in the other $k$ colorings. Because the parity of the number of red cells in a given region under the modulo $2$ sum of colorings is simply the sum of the parities under each individual coloring, every rectangle of $n=2^k$ cells will contain an odd number of red cells overall. Thus, $n=2^k$ is good.

Answer: all positive integers $n$

Grading guidelines:
(Partial) 1. Established the odd-prime step: showed that if a coloring works for n then it also works for pn for an odd prime p, by subdividing any pn-cell rectangle into p disjoint n-cell rectangles (using that one side length must be divisible by p). 2. Gave a correct explicit periodic coloring for some power of 2 (e.g. n=2 or n=4), and proved that every rectangle of area n has odd red parity in that case. 3. For n=2^k, described the grid-lattice coloring for a fixed shape 2^m×2^{k-m} (cells with x≡0 mod 2^m and y≡0 mod 2^{k-m}) and correctly computed that rectangles of that shape have odd parity (even if the treatment of other shapes / the final combination is missing). (Almost) 1. Proved that all n are good by combining (i) the closure under multiplication by odd primes and (ii) a construction for n=2^k, but left a small gap in the subdivision argument for pn (e.g. did not justify why one side must be divisible by p). 2. For n=2^k, correctly set up the k+1 shape-specific colorings and the XOR/mod-2 sum, but did not fully justify the parity claim that the “non-matching” shapes contribute an even number of red cells. 3. Solution is almost complete, but made minor mistakes which are not negligible.