João's drawing pad is a huge Cartesian grid. One of his favorite drawings is creating snakes covering the sides of the little squares with his pen. Essentially, a snake is a sequence of $2 n$ distinct points $P_{1}, P_{2}$, $\ldots, P_{2 n}$ chosen at the vertices of the grid squares such that points with consecutive indices are on the side of the same grid square. For example, in the figure below, we have a snake connecting the following points on the Cartesian plane:

$$
\begin{aligned}
& P_{1}=(0,0), \quad P_{2}=(1,0), \quad P_{3}=(1,1), \quad P_{4}=(1,2), \quad P_{5}=(2,2), \quad P_{6}=(2,3) \\
& P_{7}=(3,3), \quad P_{8}=(4,3), \quad P_{9}=(4,4), \quad P_{10}=(5,4), \quad P_{11}=(6,4), \quad P_{12}=(6,5)
\end{aligned}
$$

![](https://cdn.mathpix.com/cropped/2024_05_01_4747cb56a5540358921fg-38.jpg?height=851&width=845&top_left_y=979&top_left_x=503)

After drawing snakes on the board, João likes to calculate the sum of the coordinates of the points with odd indices, that is, the points $P_{1}, P_{3}, \ldots, P_{2 n-1}$, and subtract from this number the result of the sum of the coordinates of the points with even indices, that is, the points $P_{2}, P_{4}$, $\ldots, P_{2 n}$.

a) For $n=3$, that is, with 6 points, draw "snakes" where the result obtained by João is $-1, -3$, 1, and 3.

b) Depending on $n$, what are the possible values that João can obtain?

Note: The "snake" can also contain points with negative coordinates, as long as it "moves" to the left of the $y$-axis or below the $x$-axis.
Solution

a) The figure below shows how to obtain the values $-1,1,3 \text{ and } -3$ for the case $n=3$.
![](https://cdn.mathpix.com/cropped/2024_05_01_4747cb56a5540358921fg-39.jpg?height=422&width=1146&top_left_y=622&top_left_x=548)

b) Let $S\left(P_{n}\right)$ be the sum of the coordinates of the point $P_{n}$ and $S$ be the number obtained by João. We want to calculate the possible values of $S$.

$$
\begin{aligned}
S & =\left(S\left(P_{1}\right)+S\left(P_{3}\right)+\ldots+S\left(P_{2 n-1}\right)\right)-\left(S\left(P_{2}\right)+S\left(P_{4}\right)+\ldots+S\left(P_{2 n}\right)\right) \\
& =\left(S\left(P_{1}\right)-S\left(P_{2}\right)\right)+\left(S\left(P_{3}\right)-S\left(P_{4}\right)\right)+\ldots+\left(S\left(P_{2 n-1}\right)-S\left(P_{2 n}\right)\right)
\end{aligned}
$$

Note that each difference $\left(S\left(P_{x}\right)-S\left(P_{x+1}\right)\right)$ is equal to 1 or -1 because they are vertices of the same small square on the graph paper. Thus, $S$ is the sum of $n$ terms $\pm 1$, that is,

$$
S= \pm 1+ \pm 1+\ldots \pm 1
$$

The maximum sum is $n$, when all terms are +1, and the minimum is $-n$, when all are -1. Can $S$ take any value between $n$ and $-n$? Note that if $n$ is even, $S$ is the sum of an even number of odd terms, which naturally produces an even number. If $n$ is odd, $S$ is the sum of an odd number of odd terms, which naturally produces an odd number. Therefore, $S$ can only take values that differ from $n$ by an even number, that is, values in the set

$$
A=\{-n,-(n-2), \ldots, n-2 l, \ldots, n-2, n\}
$$

The previous example provides an idea of how to show that any number of the form $k=n-2 l$ in the set $A$ can be obtained.

Draw a "snake" with length $n+k=2 n-2 l$ on the $y$-axis and length $n-k=2 l$ on the $x$-axis as indicated in the drawing below

![](https://cdn.mathpix.com/cropped/2024_05_01_4747cb56a5540358921fg-40.jpg?height=568&width=602&top_left_y=384&top_left_x=630)

The segments on the $y$-axis will contribute the number $\frac{n+k}{2}=n-l$ and those on the $x$-axis will contribute the number $-\frac{n-k}{2}=l$. The total result is $\frac{n+k}{2}-\frac{n-k}{2}=k$.