A robot moves in the plane in a straight line, but every one meter it turns $90^{\circ}$ to the right or to the left. At some point it reaches its starting point without having visited any other point more than once, and stops immediately. What are the possible path lengths of the robot?
Problem
Source: Baltic Way 2023/7
Tags: combinatorics
11.11.2023 23:31
a_507_bc wrote: A robot moves in the plane in a straight line, but every one meter it turns $90^{\circ}$ to the right or to the left. At some point it reaches its starting point without having visited any other point more than once, and stops immediately. What are the possible path lengths of the robot? Assume that the robot first moves from $(0,0)$ to $(1,0)$. Then the $x,y$-coordinates $\mod{2}$ repeat the following patern every $4$ steps: $(0,0),(1,0),(1,1),(0,1)$. So the path lenght $n$ is divisible by $4$. It is easy for see that $n=4$ works and $n=8$ does not work. All path lenght $4n$ with $n\geq3$ can be achieved by the following path: $(0,0), (1,0), (1,-1), (2,-1), (2,0), (3,0), (3,1), (4,1), (4,2), (5,2), \ldots, (n,n-3), (n,n-2), (n-1,n-2), (n-1,n-1), (n-2,n-1), (n-2,n-2), (n-3,n-2), (n-3,n-3),\ldots, (0,1), (0,0)$.
20.05.2024 13:45
Let $U, D, R, L$ represent the directions Up, Down, Right and Left respectively. Since the robot returns to the starting point, $R = L$ and $U = D$. Hence the number of moves in total is even. Call Group $x$: $[R, L]$ and Group $y$: $[U, D]$. Converting the problem statement, two adjacent moves should be from different groups. Wlog, suppose that the robot starts with an $x$ move. Consider the series: $[x, y, x, y . . .]$. Since it contains even amount of moves, $x = y \Rightarrow R + L = D + U \Rightarrow 2 \cdot R = 2 \cdot U \Rightarrow R = U \Rightarrow U = D = R = L \Rightarrow 4 \mid length$ See that the following algorithm generates a path of length $4 \cdot k$ where $k \in \mathbb{Z}^+$ $- \{2\}$ $\underbrace{U, R, U, R, U, R . . .}_{\text{k - 1 times}}$ , $D, R$ , $\underbrace{D, L, D, L, D, L . . .}_{\text{k - 1 times}}$ , $U, L$ When this algorithm is applied for $k = 2$ it passes from the same point twice. It can be seen by trial and error that $k = 2$ doesn't work at all.