Recursive (Counting) Intermediate

Problem - 2480

Joe wants to write $1$ to $n$ in a $1 \times n$ grid. The number 1 can be written in any grid, while the number $2$ must be written next to $1$ (can be at either side) so that these two numbers are together. The number 3 must be written next to this two-number block. This process goes on. Every new number written must stay next to the existing number block. How many different ways can Joe fill this $1 \times n$ grid?


This problem can be solved using the recursion technique. Let $P(n)$ be the number of ways to fill a $1\times n$ grid.

Assuming we have a $1\times (n-1)$ block filled. There are $P(n-1)$ ways. Now, the number $n$ can be placed at either end of this $(n-1)$ block. Hence, we have $$P(n)=2\cdot P(n-1)$$

Meanwhile, it is clear that $P(1) = 1$. Therefore $P(n)$ is a geometric sequence and the solution is $P(n)=\boxed{2^{n-1}}$.

report an error