# Houses of cards and triangular numbers

October 26, 2024 at 2:52 PM by Dr. Drang

November’s issue of *Scientific American* has a fun little puzzle about houses of cards. I solved it one way and SciAm solved it another, so I thought it worth a quick post.

The houses of cards are arranged in triangular shapes, like this:

This is an end view. SciAm has a nice 3D drawing of the houses, which you may want to look at. If you have an Apple News subscription, SciAm is one of the magazines that comes with it.

I’m showing the tilted “wall” cards in blue and the flat “floor” cards in red to help us with the calculations. The number under each house is the total number of cards needed to build that house. The question is this: Can you build a house like this with 100 cards, and if so, how many stories will it be?

Let’s start by figuring out how many cards of each type there are. Here’s a table for the houses shown above:

Stories | Wall cards | Floor cards | Total cards |
---|---|---|---|

1 | 2 | 0 | 2 |

2 | 6 | 1 | 7 |

3 | 12 | 3 | 15 |

4 | 20 | 6 | 26 |

The number of wall cards go in this sequence:

```
2
2 + 4
2 + 4 + 6
2 + 4 + 6 + 8
```

which we can rewrite as

```
2 (1)
2 (1 + 2)
2 (1 + 2 + 3)
2 (1 + 2 + 3 + 4)
```

The sums in parentheses form a familiar sequence. They are the *trianglar numbers*: 1, 3, 6, 10, … I always think of these as Gauss’s numbers because of the (perhaps apocryphal) story of how, as a schoolboy, he figured out how to quickly get the sum of the first hundred natural numbers without actually doing the summation. The sum of the first $n$ numbers is the triangular number

So the number of wall cards for an $n$-story house is twice the associated triangular number

$$2\phantom{\rule{thinmathspace}{0ex}}\frac{n(n+1)}{2}=n(n+1)$$The number of floor cards is also based on triangular numbers, but we have to account for the lack of floor cards on the bottom story. The number of floor cards for an $n$-story house is the $(n-1{)}^{\mathrm{th}}$ triangular number:

$$\frac{(n-1)[(n-1)+1]}{2}=\frac{n(n-1)}{2}$$I suppose it shouldn’t be a surprise to learn that triangular numbers play a role in building triangular houses.

Adding the floor and wall cards together, we get

$$n(n+1)+\frac{n(n-1)}{2}=\frac{3{n}^{2}+n}{2}$$You can confirm this by checking it against the table above.

Now that we have the formula, we can answer the question. We solve

$$\frac{3{n}^{2}+n}{2}=100$$for $n$. This is a 2nd-degree equation, which we can put in standard form,

$$3{n}^{2}+n-200=0$$and use the quadratic formula to solve:

$$n=\frac{-1\pm \sqrt{{1}^{2}-4(3)(-200)}}{2(3)}=\frac{-1\pm \sqrt{2401}}{6}$$ $$n=\frac{-1\pm 49}{6}$$The positive solution (which is the one we care about) is $n=8$. Because this is an integer, the full answer is *Yes, we can build a house like this with 100 cards. It will have 8 stories.*

(Since we all have computers, another obvious solution is to make a spreadsheet with one column of stories and another with the formula. When the number in the stories column is 8, the number in the cards column will be 100.)

When I opened the link to see SciAm’s solution, I was surprised to see that they didn’t do it my way. Instead, they used the table of stories and cards to take differences, like this:

The 1st differences come from subtracting sequential elements in the Cards column:

$$7-2=5$$ $$15-7=8$$ $$26-15=11$$Similarly, the 2nd differences come from subtracting sequential elements in the 1st differences column:

$$8-5=3$$ $$11-8=3$$(The SciAm article includes a 5-story house, which has 40 cards, so it also includes another set of differences. I didn’t bother with the fifth house because I figured 4 stories was enough to get the idea across.)

Since the 2nd differences are constant, the formula for the number of cards must be of the 2nd degree. Differences are like derivatives, so if the 2nd differences are constant, so must be the 2nd derivative of the underlying equation. Therefore, the highest powered term in the formula for the number of cards must be a multiple of ${n}^{2}$.

In general, a 2nd degree formula will be of the form

$$a{n}^{2}+bn+c$$and we can figure out the three coefficients by plugging in three values for $n$ and solving the resulting three simultaneous equations:

$$a(1{)}^{2}+b(1)+c=2$$ $$a(2{)}^{2}+b(2)+c=7$$ $$a(3{)}^{2}+b(3)+c=15$$The solution is

$$a=\frac{3}{2},\phantom{\rule{1em}{0ex}}b=\frac{1}{2},\phantom{\rule{1em}{0ex}}c=0$$which, of course, matches the solution we got using triangular numbers.

While it was very easy for me to write “The solution is,” solving three simultaneous equations by hand is actually a pain in the ass, so I don’t much care for SciAm’s solution. Too much effort.

But I’ve never spent much time doing difference calculations, and looking at the difference table, I wonder whether there’s an easier way to get the coefficients from it. I’m sure it’s no coincidence that the 2nd derivative of

$$\frac{3{n}^{2}+n}{2}$$is 3, the same as the 2nd differences in the table. So SciAm could have figured out that the value of $a$ is $\frac{3}{2}$ straight from that. And I suspect there are similarly clever ways to work out the values of $b$ and $c$ directly from the difference table without going through the labor of simultaneous equations. Maybe I should spend some time learning more about difference tables.