4. The board is a $(2 n+1) \times(2 n+1)$ table in one of whose corners a spider is located. In one move, the spider can move one or two cells vertically or diagonally, or one cell horizontally. What is the minimum number of moves required for the spider to visit all the cells on the board? (We consider the cell the spider stands on at the start, as well as the cell it reaches at the end, as cells that have been visited; also, if the spider makes a move in which it moves two cells, we consider that the spider has visited the cell between them as well.)
4. First, let's show that it is possible to traverse the board in $n(2 n+1)+2 n=2 n^{2}+3 n$ moves. This number of moves can be achieved if the spider moves vertically two squares along each column until it has traversed the entire column, then moves horizontally one square to the next column and repeats the process until the end of the board. Now let's show that this is the smallest possible number of moves. We color all the squares in the odd rows black. We see that in each move, the set of newly traversed squares can contain at most one black square. The total number of untraversed black squares at the beginning (that is, all black squares except the starting one) is equal to $(n+1)(2 n+1)-1=2 n^{2}+3 n$, hence it follows that exactly this many moves are minimally necessary for the spider to traverse all squares.