I came along this one problem, but I don't know from where to approach it; the problems states:

You are on a point in a 2D grid, and your only valid moves are up, down, left and right, 1 unit a a time. There also are cylinders, in the middle of each 1 unit square region the grid makes. When you move from one position to another, you always walk between two of those cylinders, which each of them rotate 90 degrees clockwise or counterclockwise, depending if it is on your right or left, respectively. The question says as follows: Is it possible for a path to start and end in different positions, and reset every rotation of the cylinders to it's initial state?

I start by defining the set of valid positions for a person $V_p=\{a+bi\mid a,b\in\mathbb{Z}\}$, and the position of the cylinders as $V_c=\{\frac{1+i}{2}+v_p\mid v_p\in V_p\}$. I map the valid rotations of the cylinder from $\{0^\circ,90^\circ,180^\circ,270^\circ\}$ to $V_r=\{0,1,2,3\}$. I also map the moves $\{\text{up, down, right, left}\}$ to $M=\{i,-i,1,-1\}$, so a path $T$ is defined as $T=(t_1,\dots,t_2),\enspace t_i\in M$.

So, the position of the person after $n$ steps would be $\sum\limits_{i=0}^{n}t_i$, namely,


I define the starting position as $p(0)=0$.

When making a $n$-th step, the position of the cylinder which is in the left of that step is given by


and the one on the right by


It is true that $v_L,v_R\in V_c$.

I also define $N_L$ and $N_R$ as the number of times a path has passed from left and right, respectively. So,

$$N_L(v_c)=|\{k\mid v_c=v_L(k),\enspace k=1\dots|T|\}|$$ $$N_R(v_c)=|\{k\mid v_c=v_R(k),\enspace k=1\dots|T|\}|$$

And the rotation of any cylinder is defined as the number of times the path has passed from the left minus the number of times the path has passed from the right, modulo 4. So,


I define all the initial rotations to be $0$.

All the rotations are resetted when

$$\forall v\in V_c:R(v)=0$$


If the path starts and ends in different positions, that means that $p(|T|)\neq0$, so the goal here is to show that if the paths doesn't end where it starts, then there exists some rotation which has not been resetted. Or

$$p(|T|)\neq 0\longrightarrow \exists v\in V_c:R(v)\neq 0\mod{4}$$

And this is where I need help.


Actually, this problem can extend to any regular tesselation, so I consider any solution in any regular tesselation valid.

  • $\begingroup$ After the first move, two cylinders have been rotated by 90 degrees. Just focus on those two cylinders. There are 7 segments that can affect those two cylinders. Regardless of the path traversed, just keep track of the history with respect to those segments. $\endgroup$
    – quasi
    Feb 10, 2017 at 13:49
  • $\begingroup$ Ignore my previous comment -- it's not that simple. Sorry. $\endgroup$
    – quasi
    Feb 10, 2017 at 14:01
  • $\begingroup$ Is it an infinite grid? $\endgroup$
    – Jens
    Feb 12, 2017 at 21:19
  • $\begingroup$ @Jens Yes it is, but the path is not. $\endgroup$
    – Garmekain
    Feb 12, 2017 at 23:33

1 Answer 1


You will not be able to find a proof for arbitrary sized grids. Consider the grid {0,1,2} X {0,1}.

We can build a solution with two primitives, which can be reversed and rotated for all possible orientations.

Non-corner to non-corner. initial position (1,0) and target (1,1). The walk (1,0),(2,0),(2,1),(1,1),(1,0),(0,0),(0,1),(1,1) is a satisfying walk.

Corner to non-corner: Initial position (2,0) and target (1,1). The walk (2,0),(2,1),(1,1),(1,0),(0,0),(0,1),(1,1),(1,0),(0,0),(0,1),(1,1).

(Edit) For the {0,1,2} x {0,1,2} grid there is a length-22 walk from (1,0) to (2,1) which satisfies your conditions. Namely, (1,0),(2,0),(2,1),(1,1),(1,0),(0,0),(0,1),(0,2),(1,2),(1,1),(0,1),(0,2),(1,2),(1,1),(0,1),(0,2),(1,2),(1,1),(0,1),(0,2),(1,2),(2,2),(2,1).

My insight: Both of these solutions use repeated partial traversals of 4-cycles to correct "imbalances" of neighboring cells. I conjecture that there are solutions for a large family of grids, but the start and end positions are necessarily on the perimeter.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .