The problem

In how many ways you can arrange $p$ coins in a sequence of towers? (it doesn't matter whether the coins can be flipped or rotated, and we assume that there are no empty towers).

For example, here is one way to arrange $12$ coins into a sequence of $5$ towers. The problem asks to count all these ways.

Motivation

I arrived at this problem by being inspired by my yesterday's post, A combinatorial problem with balls and boxes. The problem was to count the number of ways you can place $k$ balls in $n$ boxes. The answer is $n-1+k$ choose $k$, which is $\displaystyle{\frac{(n-1+k)!}{(n-1)!k!}}$.

So I asked myself, since the result is of the form "$p$ choose $q$",  couldn't I modify the problem so that the result will be the sum over $q$, which is known to be $2^p$? But to do this, boxes and balls should be replaced with objects of the same nature, and playing the role of a box or a ball to be determined by the configuration.

I will tell you a solution by reducing to the problem with boxes and balls, and then a simpler, direct solution.

Solution based on the balls and boxes problem

Let's  identify two distinct roles in a sequence of towers of coins. We color each coin that starts a tower with blue, and the others with red, as below.

We can now consider that the blue coins are boxes, and the red coins are balls, and reduce to the previous problem. The number of possible ways to put $k$ balls in $n$ boxes is $n-1+k$ choose $k$, which is also $n-1+k$ choose $n-1$. In our case, the number of boxes equals the number of towers, so it is $n$, and the number of balls is $p-n$. So, the number of possible ways to arrange $p$ coins in $n$ towers is $n-1+(p-n)=p-1$ choose $n-1$. Since we can have any number of towers, from $n=1$ to $n=p$, we have to sum accordingly, and the total number is $\sum_{n=1}^p \left( \begin{array}{c} p-1\\n-1 \end{array} \right)=\sum_{q=0}^{p-1} \left( \begin{array}{c} p-1\\q \end{array} \right)=2^{p-1}.$

This solution is based on the problem of balls in boxes, which inspired the very problem. But since we've got $2^{p-1}$, shouldn't be a simpler and direct way to count all possible configurations?

Simpler solution

Rather than coloring the coins as previously, let's color the even towers with red, and the odd towers with blue.

We see now that any sequence of colors of the $p$ coins starting with blue corresponds to a way to arrange them in towers, and conversely. For example, the above arrangement corresponds to the sequence BBRRRRBBBRBB. The first coin has to be blue, but each of the other $p-1$ can be chosen in two ways. Hence, the number of all such sequences is $2^{p-1}$.