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. Proposed by Merlijn Staps
Problem
Source: 2023 USA TSTST Problem 3
Tags: combinatorics, USA TSTST
26.06.2023 19:27
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: (i) If $n$ is good and $p$ is an odd prime, then $pn$ is good; (ii) For every $k \ge 0$, the number $n=2^k$ is good. Together, (i) and (ii) imply that all positive integers are good. 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$ rectangles consisting of $n$ cells. Thus 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\leq m \leq k$. Claim: For each of these $k+1$ shapes, there exists a coloring with two properties: Every rectangle with $n$ cells and shape $2^m\times 2^{k-m}$ contains an odd number of red cells. Every rectangle with $n$ cells and a different shape contains an even number of red cells. Proof. This can be achieved as follows: assuming the cells are labeled with $(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}}$. For example, a $4 \times 2$ rectangle gets the following coloring: [asy][asy] unitsize(12); int a = 4, b = 2; int n = a*b; real extra = 0.25; transform t = scale(1, -1); for (int i = 0; i <= n; i += a) for (int j = 0; j <= n; j += b) fill(t * shift(i, j) * unitsquare, red); clip(t*box((-extra, -extra), (n+extra, n+extra))); for (int i = 0; i <= n; ++i) { draw(t*((i, -extra)--(i, n+extra))); draw(t*((-extra, i)--(n+extra, i))); } [/asy][/asy] A $2^m\times 2^{k-m}$ rectangle contains every possible pair $(x\mod{2^m}, y\mod {2^{k-m}})$ exactly once, so such a rectangle will contain one red cell (an odd number). On the other hand, consider a $2^{\ell}\times 2^{k-\ell}$ rectangle with $\ell > m$. The set of cells this covers is $(x, y)$ where $x$ covers a range of size $2^{\ell}$ and $y$ covers a range of size $2^{k-\ell}$. The number of red cells is the count of $x$ with $x\equiv 0\mod{2^m}$ multiplied by the count of $y$ with $y\equiv 0\mod{2^{k-m}}$. The former number is exactly $2^{\ell-k}$ because $2^k$ divides $2^{\ell}$ (while the latter is $0$ or $1$) so the number of red cells is even. The $\ell < m$ case is similar. $\blacksquare$ Finally, given these $k+1$ colorings, we can add them up modulo $2$, i.e.\ a cell will be colored red if it is red in an odd number of these $k+1$ colorings. We illustrate $n=4$ as an example; the coloring is $4$-periodic in both axes so we only show one $4\times 4$ cell. [asy][asy] unitsize(0.5cm); int pow2(int k) { int n = 1; for (int i = 0; i < k; ++i) { n *= 2; } return n; } int k = 2; int n = pow2(k); int XSHIFT = 0; void draw_grid() { for (int i = 0; i <= n; ++i) { draw((XSHIFT+i, 0)--(XSHIFT+i, n)); draw((XSHIFT+0, i)--(XSHIFT+n, i)); } } void fill_cell(int i, int j) { fill((XSHIFT+i, j)--(XSHIFT+i+1, j)--(XSHIFT+i+1, j+1)--(XSHIFT+i, j+1)--cycle, red); } void draw_single(int m) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i%pow2(m) == 0 && j%pow2(k-m) == 0) { fill_cell(i, j); } } } draw_grid(); XSHIFT += n; } void draw_sum() { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { int cnt = 0; for (int m = 0; m <= k; ++m) { if (i%pow2(m) == 0 && j%pow2(k-m) == 0) { ++cnt; } } if (cnt%2 == 1) { fill_cell(i, j); } } } draw_grid(); XSHIFT += n; } void draw_symbol(string s) { label(scale(2)*s, (XSHIFT+1, n/2), blue); XSHIFT += 2; } for (int i = 0; i < k; ++i) { draw_single(i); draw_symbol("$\oplus$"); } draw_single(k); draw_symbol("$=$"); draw_sum(); [/asy][/asy] This solves the problem. Remark: The final coloring can be described as follows: color $(x, y)$ red if \[\max(0, \min(\nu_2(x), k)+\min(\nu_2(y), k)-k+1)\]is odd. Remark: [Luke Robitaille] Alternatively for (i), if $n = 2^e k$ for odd $k$ then one may dissect an $a \times b$ rectangle with area $n$ into $k$ rectangles of area $2^e$, each $2^{\nu_2(a)} \times 2^{\nu_2(b)}$. This gives a way to deduce the problem from (ii) without having to consider odd prime numbers.
26.06.2023 22:53
I know this sounds very absurd, but... Laurent series, anyone? Edit: By Laurent series I mean gen func, one of my specialities for which I am infamous (not that I am able to use it well).
27.06.2023 00:00
The answer is all \(n\). Claim: The problem holds for \(n\) a power of two. Proof. Base cases of \(n=1\) and \(n=2\) are easily verified. We prove that the problem for \(n=2^{k-2}\) implies the problem for \(n=2^k\). The construction for \(n=2^k\) is as follows: Partition the plane into \(2\times2\) squares, and color the top-left corner of each \(2\times2\) square according to the construction for \(n=2^{k-2}\). Coloring everything else white. Then, toggle the color of every square \((x,y)\) so that either \(2^k\mid x\) or \(2^k\mid y\), but not both. (We can think of this as toggling all the \(0\bmod2^k\) rows and \(0\bmod2^k\) columns, thereby leaving the intersections of these rows and columns unchanged.) Of course the valid coloring for \(n=2^{k-2}\) is periodic modulo \(2^{k-2}\) in each direction, so our construction after (1) is periodic modulo \(2^{k-1}\) in each direction. After (1), Each \(1\times2^k\) or \(2^k\times1\) rectangle passes through two periodic copies of the same pattern, but step (2) toggles exactly one square (or all but one square), so the number of red squares is odd. On the other hand, for each \(2a\times2b\) rectangle where \(ab=2^{k-2}\), the cells of the \(2a\times2b\) rectangle with both even coordinates are the only cells that may be red after (1), and they form a \(a\times b\) rectangle in the corresponding construction for \(n=2^{k-2}\), so it contains an odd number of red squares. Since both dimensions of the \(2a\times2b\) rectangle are even, (2) only adjusts the color of squares an even number of times, so there are still an odd number of squares. \(\blacksquare\) Finally, if \(n=2^k\cdot t\) for some odd \(t\), the construction for \(n=2^k\) also works for \(n=2^k\cdot t\). After all, for each \(a\times b\) rectangle, we may write \[a=2^e\cdot a'\quad\text{and}\quad 2^f\cdot b'\]for odd \(a'\) and \(b'\), with \(2^e\cdot 2^f=2^k\). Therefore the \(a\times b\) rectangle may be partitioned into \(a'b'\) rectangles of dimension \(2^e\times2^f\). We have an odd number of rectangles, each with an odd number of red squares, so the total number of red squares is odd.
27.06.2023 09:20
If IMO 1 geo were this easy. The answer is all $n$. We first provide constructions for powers of 2. Let $n=2^k$. Let $f\colon (\mathbb{Z}/2^k\mathbb{Z})^2 \to \mathbb{F}_2$ such that $f(x,y)$ is 1 iff it is red. A direct construction seems hard, but after some experimentation, we find that it is not too hard to make sure the sum of $f$ in any $2^a \times 2^{k-a}$ rectangle is 1 for some fixed $k$. Motivated by this, we go into our construction: For each $j=0,\cdots,k$, we construct such $f$ such that the sum of any $2^a\times 2^{k-a}$ rectangle is $0$ if $a\ne j$ and is $1$ otherwise. Let our construction be $f_j(x,y) = 1_{2^a\mid x} 1_{2^{k-a}\mid y} $. Note in any $2^j\times 2^{k-j}$ rectangle, the number of $(x,y)$ such that $2^j\mid x, 2^{k-j} \mid y$. When $a>j$ the number of $1$'s in a $2^a \times 2^{k-a}$ rectangle such that $2^j\mid x$ is even, so the number of 1's in this rectangle is even is (number of $x$ such that $2^j\mid x$ in range) $\times$ (number of $y$ such that $2^{k-j}\mid y$ in range). A similar argument applies for $a<j$. Therefore the construction $\sum\limits_{l=0}^k f_l$ works solves the problem for $n=2^k$. Now, if $n=2^kq$ where $q$ is odd, then the same construction for $2^k$ works; any $2^jq_1 \times 2^{k-j}q_2$ can be partitioned into $q_1q_2$ rectangles of size $2^j\times 2^{k-j}$, and each of these have an odd number of 1's.
27.06.2023 16:46
Solved with an IMO team member (mostly him). The answer is all positive integer $n$. Replace "red" and "not red" with $1$ and $0$ respectively. Claim: It is possible for all positive integers $2^k$ for $k=0,1,2,\ldots$. The motivation: we take $k+1$ labellings $\mathcal L_0,\mathcal L_2,\ldots, \mathcal L_k$ where the square $(x,y)$ has a $1$ in $\mathcal L_t$ if and only if $2^t\mid x$ and $2^{k-t}\mid y$. Then, in the final labelling: $$L(x,y)= \begin{cases} 1 & \text{ if }(x,y)\text{ is }1\text{ in an odd number of }\mathcal L_t\text{'s}\\ 0 & \text{ if }(x,y)\text{ is }1\text{ in an even number of }\mathcal L_t\text{'s} \end{cases} $$To prove that any rectangle of the form $2^a\times 2^{k-a}$ for $a=0,1,\ldots, k$ ($2^a$ in width, $2^{k-a}$ in height) has an odd number of $1$'s, we will show that $2^a\times 2^{k-a}$ has an odd number of $1$'s in $\mathcal L_t$ if and only if $t=a$. If $t=a$, the result is evident - there is exactly one $1$ of $\mathcal L_a$ in any $2^a\times 2^{k-a}$ rectangle. If $t<a$, then any row of the $2^a\times 2^{k-a}$ rectangle containing a $1$ contains $\frac{2^a}{2^t}=2^{a-t}$ $1$'s, which is an even number. Thus, there is an even number of $1$'s in the rectangle. The $t>a$ case can be handled similarly (columns). In the final labelling $L$, for any $2^a\times 2^{k-a}$ rectangle let $S_i$ be the sum of entries of the rectangle under labelling $\mathcal L_i$ for $i=0,1,\ldots, k$. Thus, the number of $1$'s in the rectangle under $L$ has same parity as: $$S_0+S_1+\cdots + S_k = (S_0+S_1+\cdots+ S_{a-1}+S_{a+1}+\cdots +S_k)+S_a$$which is odd, as needed. Thus, it is possible for any $n=2^k$ for integer $k\geq 0$. $\square$ To finish, let $n=2^kr$ where $r$ is an odd integer and use the labelling for $2^k$. For rectangle with dimensions $a\times b$ ($ab=n$) take $c,d$ such that $2^c\mid a, 2^d\mid b$ and $c+d=a$. Then partition the $a\times b$ rectangle into $r$ rectangles of size $c\times d$: each of these contain an odd number of $1$'s, so the total number of $1$'s in the $a\times b$ rectangle is congruent to $r$ which is odd.
27.06.2023 18:28
The same as CANBANKAN's,quite an ez problem for USA TSTST P3
28.06.2023 08:11
Solved with TheBeast5520 and RubiksCube3.1415. The answer is all $n$. First we show that $n=2^k$ is possible for $k\ge 0$, then we show that the construction for $2^k$ works for any $n$ with $\nu_2(n)=k$.
28.06.2023 08:14
Solved this as a graduated 2nd grader and now rising 3rd grader while mocking the 2023 USA TSTST Day 1.
29.06.2023 22:21
interesting. I claim it is possible for all $n$. Observe the following: Notice that each row and column repeats every $n$ squares. We thus consider only a $n \times n$ grid and let rectangles wrap around. Proving it works for an $n\times n$ grid with wrapping rectangles with show it works on an infinite grid. Claim: It is possible for $n=2^k$ for $k\geq 0$. Proof. Proceed with (2-step) induction on $k$. The base cases are $k=0$ where a full red grid works and $k=1$ alternating red and blue work. Assume it is true up to $k=j,$ we show its true for $k=j+2.$ First, we present a construction. We show true for an $2^{j+2}\times 2^{j+2}$ square and then repeat that square for the rest of the grid. Also, WLOG ket the bottom left corner or the square be $(1,1)$ and each cell in the grid is one unit. Also, let $2^j$ be $m$ so our goal is to show true for a $4m\times 4m$ grid. Construction. Color the cell $(1,1)$ red. Also, color the squares on the union of the lines from $(2m,2)$ to $(2m,4m)$ and $(2,2m)$ to $(4m,2m)$ and call these the center cross and $(2m,2m)$ the center. Then, consider where the red sqaures the construction for $m$ and remove the bottom row and left most column. Then, dilate it out from its new center by a scale of $2$ (so a point $x$ away from the center is sent to $2x$ units away), color everything else blue, and place this new configuration in the grid $4$ times, centered at $(m+1,m+1),(3m,m+1),(m+1,3m),(3m,3m).$ I claim this is a valid arrangement. Proof of construction. Notice that by construction, the red square at $(1,1)$ isnt in a rectangle with area $4m$ with any other red square so it works. Also, all other $1\times m$ or $m\times 1$ work by symmetry, Now, consider a rectangle not passing through this point and with both dimensions at least $2$. We have three cases: Case 1. The rectangle does not pass through the center cross. This case is easy, since if we dilate all red points centered at $(m+1,m+1)$ with ratio $1/2,$ we are simply left with the $m$ case which by hypothesis works. Case 2. The rectangle passes through the center cross but not the center. If it intersects the vertical one, lay $4m-1$ disjoint copies of it to its left (wrapping around) to make a big rectangle that has length $4m$. Since the height of this ractangle divides $4m$ and is not one, it must be even so the amount if rectangles in it is even by considering $m\times 1$ rectangles. But none of the other $4m-1$ laid down pass through the center cross meaning they all have an odd amount of red tiles. But there's an odd amount if these so the total in the $4m-1$ other rectangles must be odd and thus the original must have odd total. Horizontal is the same but lay them above. Case 3. The rectangle passes through the center. This case is the same as above in process: lay rectangles to the left and wrap around all of which have an odd amount of red tiles. These cases are exhaustive and disjoint, so thus such a coloring is possible for $n=4m$. This completes the indiction and the claim is thus proven. Now we are left with the easy part! To show its true for all $m$, repeat the construction for a $n=2^{v_2(m)}.$ This works since each rectangle with area $m$ can be split up into an odd amount of rectangles with area $2^{v_2(m)}$. We are thus done. Remark. Here are some more constructions you can see how they were made using the case two powers of two before. Shaded squares are red.
08.03.2024 19:01
Very Nice problem! Sketch (since write up is long) The answer is all $n$. Firstly notice that it suffices to prove a construction for $n=2^k$, to do this we proceed by 2 step induction. Say the bottom left square $(1,1)$, and color that red, then draw a center cross in the square not containing cells of "hook" of the bottom left square. The idea is now to dilate our construction of $2^{k-2}$ and place that in. Now to prove this that this works, we take a few cases, first being that the rectangle doesn't pass through the center cross, it is easy to see that this works. Second, it passes through the center cross, but not through the center of cross, and third being passes through center of cross, each case being easy to verify. Hence, we're done. Remark: Another (nice)question with construction part being the pith of the problem! EDIT: 300th HSO post!
05.10.2024 21:46
Solved with Narwhal234. We claim all $n$ work. We first show that $n = 2^k$ works. Call an $(a, b)$ lattice a lattice where the squares $(ax, by)$ are colored red. Claim: For a $(2^a, 2^b)$ lattice, the number of squares in a rectangle with area $n \coloneq 2^{a+b}$ is odd iff the rectangle is $2^a \times 2^b$ (where $2^a$ is the width). Proof. If the rectangle has such dimensions it contains exactly one such square. Else, suppose the rectangle has dimensions $2^{a'} \times 2^{b'}$ for $(a, b) \ne (a', b')$. Then either $a' > a$ or $b' > b$, WLOG say $a' > a$. Then this rectangle consists of two identical side by side $2^{a'-1} \times 2^{b'}$ rectangles as $a'-1 \ge a$, so it has an even number of squares. $\blacksquare$ Now, taking the xor over all $(2^a, 2^{k-a})$ lattices for $0 \le a \le k$ works. Then for any general $n = 2^kb$ where $b$ is odd, just take the construction for $2^a$. Any $2^a p \times 2^{k-a} q$ rectangle for $pq = b$ is $b$ copies of a $2^a \times 2^{k-a}$ rectangle which has an odd number of cells, so this rectangle also has an odd number of cells. Remark: This remains the same when generalizing to coloring $\mathbb{Z}^n$.
05.10.2024 23:31
^ YaoAops did like 90% of the work lmaoooo