Larry and Rob are two robots travelling in one car from Argovia to Zillis. Both robots have control over the steering and steer according to the following algorithm: Larry makes a 90 degrees left turn after every $ \ell$ kilometer driving from start, Rob makes a 90 degrees right turn after every $ r$ kilometer driving from start, where $ \ell$ and $ r$ are relatively prime positive integers. In the event of both turns occurring simultaneously, the car will keep going without changing direction. Assume that the ground is flat and the car can move in any direction. Let the car start from Argovia facing towards Zillis. For which choices of the pair ($ \ell$, $ r$) is the car guaranteed to reach Zillis, regardless of how far it is from Argovia?
Problem
Source: APMO 2009 Q.5
Tags: algorithm, number theory, relatively prime, combinatorics
15.03.2009 18:05
My answer is all $ l$ and $ r$, if $ lr-1=4k$ for all integer $ k$
06.05.2009 14:51
I think $ 4|l-r$ is the correct one..
07.03.2010 03:39
My answer is l+r=4k-2 for all postive integer k.
25.01.2015 18:02
Any solutions ?
17.02.2016 05:12
The above answers are all correct. Here is a solution with motivation. This is an interesting problem, for there aren't as many restrictions as there may seem, because of a very strange coincidence present in the problem. In fact, as long as $\ell - r \equiv 0 \pmod{4}$, we're all good. Let's see why the other numbers don't work. The basic idea here is that after $r\ell$ moves, $\ell$ right turns will have been made, and $r$ right turns will have been made. The point is that if $\ell - r \not \equiv 0 \pmod{4}$, some simple computations show that the robots will land back at $(0, 0)$, which destroys the hypothesis. The more interesting question is, how do we show that they will reach Zillis if they keep going east? You do end with the same heading as you started with, but this seems to entail very restrictive conditions on the distance from Zillis to Argovia. However, a miracle is built into the problem. In fact, it can be shown that after $r\ell$ moves, if $\ell - r \equiv 0 \pmod{4}$, the car lands at $(1, 0)$, and it ends with the same heading. This will imply the result, so all we have to do is prove it. The second key insight here is to view the moves in the complex plane. At the $n$th minute, the move is towards $i^{\frac{n}{r} - \frac{n}{\ell}}$. Hence, it is sufficient to show that \[ \sum_{n = 0}^{r\ell-1} i^{\lfloor \frac{n}{r} \rfloor - \lfloor \frac{n}{\ell} \rfloor } = 1 \]if $r \equiv \ell \pmod{4}$. We can slightly rewrite this into \[ \sum_{n = 0}^{r\ell-1} i^{\lfloor \frac{n}{r} \rfloor} (-i)^{\lfloor \frac{n}{\ell} \rfloor } = 1 \]What follows is an incredibly clever argument. Assume that $\ell \equiv r \equiv 1 \pmod{4}$. Then, observe that \[ (i)^{r\lfloor \frac{n}{r} \rfloor - n}(-i)^{\ell \lfloor \frac{n}{\ell} \rfloor - n} = i^{\lfloor \frac{n}{r} \rfloor} (-i)^{\lfloor \frac{n}{\ell} \rfloor} \]Its not so clear why that is a simplification, but just wait and see that \[ (i)^{r\lfloor \frac{n}{r} \rfloor - n}(-i)^{\ell \lfloor \frac{n}{\ell} \rfloor - n} = (-i)^{n\pmod{r}}(i)^{n\pmod{\ell}} \]Now, $r$ and $\ell$ are relatively prime, so any ordered pair for $(n \pmod{r}, n \pmod{\ell})$ is taken exactly once by the chinese remainder theorem as $n$ ranges from $0$ to $r\ell-1$. Hence we can just write \[ \sum_{n = 0}^{r\ell-1} (i)^{r\lfloor \frac{n}{r} \rfloor - n}(-i)^{\ell \lfloor \frac{n}{\ell} \rfloor - n} = \sum_{n = 0}^{r\ell-1} (-i)^{n\pmod{r}}(i)^{n\pmod{\ell}} = \sum_{n = 0}^{r-1} (-i)^{n}\sum_{n=0}^{\ell-1}(i)^{n} = (1)(1) = 1\], so this part of the proof is complete. Inspired by this, we use a similar proof for the $\ell \equiv r \equiv 3 \pmod{4}$ case. Akin to the previous case, observe that \[ (i)^{n - r\lfloor \frac{n}{r} \rfloor}(-i)^{n - \ell \lfloor \frac{n}{\ell} \rfloor} = i^{\lfloor \frac{n}{r} \rfloor} (-i)^{\lfloor \frac{n}{\ell} \rfloor} \]Now the last sum is equivalent to $(i)^{n \pmod{r}} (-i)^{n \pmod{\ell}}$ Doing a similar argument with the Chinese remainder theorem gives that \[ \sum_{n = 0}^{r\ell-1} (i)^{n - r\lfloor \frac{n}{r} \rfloor}(-i)^{n - \ell \lfloor \frac{n}{\ell} \rfloor} = \sum_{n = 0}^{r\ell-1} (i)^{n\pmod{r}}(-i)^{n\pmod{\ell}} = \sum_{n = 0}^{r-1} (i)^{n}\sum_{n=0}^{\ell-1}(-i)^{n} = (i)(-i) = 1\]and we are done.
11.03.2017 02:19
We claim that the answer is all $\ell$ and $r$ with $4\mid \ell-r$. Note that after traveling for $k$ kilometers, the car will have turned left $\left\lfloor\frac k\ell\right\rfloor$ times and right $\left\lfloor\frac kr\right\rfloor$ times. Hence, if we place Argovia in the complex plane at the origin with Zillis on the positive real axis, then after $k$ kilometers the car will face the direction of $i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}$. Thus, after $n$ kilometers it will end up at \[\sum_{k=0}^{n-1}i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}\]and be facing in the direction of $i^{\left\lfloor\frac n\ell\right\rfloor-\left\lfloor\frac nr\right\rfloor}$. First, note that if $4\nmid \ell-r$, then \[\sum_{k=0}^{4\ell r-1}i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}=\sum_{k=0}^{\ell r-1}\left(i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}+i^{\left\lfloor\frac{k+\ell r}\ell\right\rfloor-\left\lfloor\frac{k+\ell r}r\right\rfloor}+i^{\left\lfloor\frac{k+2\ell r}\ell\right\rfloor-\left\lfloor\frac{k+2\ell r}r\right\rfloor}+i^{\left\lfloor\frac{k+3\ell r}\ell\right\rfloor-\left\lfloor\frac{k+3\ell r}r\right\rfloor}\right)\]\[=\sum_{k=0}^{\ell r-1}i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}\left(1+i^{r-\ell}+i^{2(r-\ell)}+i^{3(r-\ell)}\right)=0\]so after $4\ell r$ kilometers, the car will be back at Argovia and facing in the direction of $i^{4(r-\ell)}=1$ or Zillis. Thus, the car's position is periodic with period $4\ell r$ kilometers, so if Zillis is more than $4\ell r$ kilometers away from Argovia, there is no way that the car can reach it. Now, we claim that \[\sum_{k=0}^{\ell r-1}i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}=1\]if $4\mid \ell-r$. As $i^{\left\lfloor\frac{k+\ell r}\ell\right\rfloor-\left\lfloor\frac{k+\ell r}r\right\rfloor}=i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor+r-\ell}=i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}$, it suffices to show that \[\sum_{k=0}^{4\ell r-1}i^{\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor}=4.\]We will first count the number of $k$ between $0$ and $4\ell r-1$ satisfying $\left\lfloor\frac k\ell\right\rfloor\equiv a\pmod 4$ and $\left\lfloor\frac kr\right\rfloor\equiv b\pmod 4$ given $a$ and $b$ between $0$ and $3$. Note that $k$ satisfies the first condition iff \[k\equiv a\ell,a\ell+1,\ldots,a\ell+\ell-1\pmod{4\ell}\]and the second condition iff \[k\equiv br,br+1,\ldots,br+r-1\pmod{4r}.\]By the Chinese Remainder Theorem, we obtain a solution for $k$ modulo $4\ell r$ for each choice of the residue of $k$ modulo $4\ell$ and the residue of $k$ modulo $4r$ that are congruent modulo $4$. Now, set $\ell=4m\pm1$ and $r=4n\pm1$. Note that there are $m\pm1$ numbers in the first list that are congruent to $a\pmod 4$ and $m$ numbers that belong to each other residue class. Similarly, there are $n\pm1$ numbers in the second list that are congruent to $b\pmod 4$ and $n$ numbers that belong to each other residue class. Thus, if $4\nmid a-b$ we obtain $mn+mn+m(n\pm1)+n(m\pm1)=4mn\pm m\pm n$ such $k$ and if $4\mid a-b$ we obtain $mn+mn+mn+mn+(m\pm1)(n\pm1)=4mn\pm m\pm n+1$ such $k$. Now, we can evaluate our sum. By our work above there are $16mn\pm 4m\pm 4n+4$ values of $k$ between $0$ and $4\ell r-1$ with $4\mid \left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor$ and $16mn\pm 4m\pm 4n$ values of of $k$ between $0$ and $4\ell r-1$ with $\left\lfloor\frac k\ell\right\rfloor-\left\lfloor\frac kr\right\rfloor$ belonging to each other residue class modulo $r$. Hence, our sum equals $4$. To finish, note that after $k\ell r$ moves, the car will be facing in the direction of $i^{k(r-\ell)}=1$, or the direction of Zillis, and will be at $k$. It begins the next of its $\ell r$ moves going from $k$ to $k+1$ and thus covers the interval $[k,k+1]$. In this way, the car eventually visit any point on the positive real axis, Zillis included, as desired.
26.11.2019 02:22
Shouldn't the car be traveling in the $i^{\lfloor \frac{n}{r} \rfloor+ \lfloor \frac{n}{l} \rfloor}$ direction at time $n$?
20.09.2020 15:52
This problem has a nice visual solution, which I think deserves to be shown. (I think it's equivalent to the solution in #6.) If this solution is confusing, you may want to look at a similar diagram for BMO 2003/4, which has only two colors. As in the above solutions, if $4 \nmid \ell-r$, then after $4\ell r$ seconds the car is back to its initial state, so the task is not always possible. Now suppose $4 \mid \ell - r$. Since there are $\ell$ left turns and $r$ right turns, after $\ell r$ seconds the car is in the same direction. We claim that after $\ell r$ seconds, the car is in the same direction, but one unit ahead; this is sufficient. Color the unit square cells of an $\ell \times r$ grid along diagonals modulo $4$, as done below for $(\ell, r) = (5, 9)$. Draw the up-right diagonal of the whole rectangle; then, the colors along this diagonal correspond to the car's path. [asy][asy] unitsize(60); int m = 5, n = 9; pen[] dark = {gray(0.4), deepcyan, black, olive}; pen[] light = {gray(0.8), lightcyan, gray(0.6), lightyellow}; dark.cyclic = true; light.cyclic = true; for (int i = 0; i < m; ++i) for (int j = 0; j < n; ++j) fill(shift(j,i)*unitsquare, light[i-j]); int col = 0; for (int i = 0; i < m*n; ++i) { if (i%m==0) col -= 1; if (i%n==0) col += 1; draw((i/m, i/n)--((i+1)/m, (i+1)/n), dark[col]); if (i >= m || i >= n) draw(((i%m)/m, (i%n)/n)--((i%m+1)/m, (i%n+1)/n), dark[col]); } draw(box((0,0), (n,m))); for (int i = 1; i <= n-1; ++i) draw((0,i/n)--(1,i/n), dotted); for (int j = 1; j <= m-1; ++j) draw((j/m,0)--(j/m,1), dotted); [/asy][/asy] The idea is to now shift all these segments of the diagonal into the lower-left cell. (This is somewhat opposite of the usual tactic in "reflection" problems.) Since $\gcd(\ell, r) = 1$, we can partition this cell into an $r \times \ell$ grid so that these segments are the up-right diagonals in these tiny cells. However, as seen in the image, there is a surprise: The surprise. The colors of the segments in these cells form a diagonal coloring modulo $4$, as in the larger grid, and the colors appear in the same cyclic pattern (but perhaps reversed). This surprise isn't hard to prove once noticed, so I'll omit the proof. (The hypothesis $4 \mid \ell - r$ is crucial, as it implies $\ell \equiv r \equiv \pm 1 \pmod 4$). Now the problem is not difficult. We now only operate inside the lower-left $1 \times 1$ square. WLOG assume that the colors appear as above, with cyan directly below light-gray. Associate the colors light-gray, cyan, dark-gray, and yellow with $1$, $i$, $-1$, and $-i$ respectively. Then the total sum inside the lower-left cell equals \[ (1 + i + \dots + i^{\ell-1}) (1 + i^{-1} + \dots + i^{-(r-1)}). \]Now we can finish off the problem: If $\ell \equiv r \equiv 1 \pmod 4$ then the product equals $1 \cdot 1 = 1$, as desired. If $\ell \equiv r \equiv 3 \pmod 4$ then the product equals $(-1) \cdot (-1) = 1$, as desired. We've shown that the net displacement after $\ell r$ seconds is one unit forward, as wanted.
06.03.2024 19:24
The answer is $l,r$ with $l\equiv r\pmod{4}$. If $l\not\equiv r\pmod{4}$, then the car has a net directional change every $rl$ kilometers, and hence moves in a cycle. If $l\equiv r\pmod{4}$, then the car still faces toward the destination after $lr$ kilometers. We will show that the net displacement every $lr$ kilometers is exactly $1$ kilometer toward the destination. Indeed, placing everything on the complex plane with the destination on the positive real axis, the displacement after $rl$ kilometers is $$\sum_{k=1}^{lr} i^{\lfloor \frac{k}{l}\rfloor - \lfloor \frac{k}{r}\rfloor} = \sum_{k=1}^{lr} i^{\frac{k}{l} - \frac{k}{r} + \{\frac{k}{r}\} - \{\frac{k}{l}\}} = \sum_{k=1}^{lr} i^{\frac{1}{r}\left(k\bmod{r} - k\bmod{l}\right)} = (i^0 + i^{\frac{1}{r}} + \dots + i^{\frac{r-1}{r}})(i^0 + i^{-\frac{1}{r}} + \dots + i^{-\frac{l-1}{r}})$$ where exponents are taken mod $4$ everywhere and the last step follows from CRT. If $l\equiv r\equiv 1\pmod{4}$, both expressions evaluate to $1$. If $l\equiv r\equiv -1\pmod{4}$, the first expression evaluates to $-i$ and the second evaluates to $i$. Either way, we get a net displacement of $1$. Hence, for any positive integer $n$, the interval from $n$ to $n+1$ gets covered between $nrl$ and $nrl+1$ kilometers, as desired.