How many cards are there in a house of cards with r rows?
There are two ways we can approach this. One is simpler mathematically, but requires one to spot
a special property of the construction of the house. The other is somewhat more challenging, but takes
a more analytical approach in it's derivation. Of course, the equation constructed at the end
is the same. I'll go through both methods and you can read either or both as you like.
The (slightly) inspired way
Lets look at a specific house of cards just to get the picture in our minds:
/\
_/__\_
/ \ / \
/___\/___\
/ \ / \ /\
/ \/ \/ \
That's a house of cards for r = 3. You'll notice that the bottom row has no horizontal cards,
while all the other rows do. These exceptions are bound to any formula more complicated, so for now
we'll imagine that the bottom row also has these base cards. We can correct for this deliberate mistake
later; simplication is a powerful technique used by real mathematicians when getting to grips with
a new problem.
Here's our new, temporary house:
/\
_/__\_
/ \ / \
/___\/___\
/ \ / \ /\
/___\/___\/__\
Now, in true mathematical style, we can reduce this to a previously solved problem. How? Well, we
can treat each block of three cards (left slanter, right slanter and base card) as one "unit". And if we
draw these units on their own...
.
. .
. . .
A good old triangle! The formula for the nth triangular number is ½n(n+1), and a house of
cards with r rows corresponds to a triangle of ½r(r+1) units, each of which contains 3 cards. So the formula
of our slightly unorthodox house of cards is
3
C = --- · r(r+1),
2
where C is the number of cards required.
Now we simply need to correct for our over-estimate in adding an extra row at the bottom. How many cards
did we add? r of course! So we simply remove that quantity from our equation and we get the true
number of cards, leaving us with the straight forward equation
3
C = --- · r(r+1) - r.
2
The analytical way
Let's start by finding the number of cards in each row. However big the house of cards, the top row has the
same number of cards, as does the next one down, and so on to the bottom of the house of cards. For this
reason, we'll number the rows in this way:
/\ 1
_/__\_
/ \ / \ 2
/___\/___\
/ \ / \ /\ 3
/ \/ \/ \
We define a row as all the leaning cards plus the horizontal cards directly above it. Thus row 1 always has 2 cards,
row 3 has 5 and so on. Let's make a quick table of the first few values of row R.
_________
| R | CR |
|----|----|
| 1 | 2 |
| 2 | 5 |
| 3 | 8 |
| 4 | 11 |
|____|____|
Now of course this method is relying on strictly analytical methods, so we're not allowed to spot the obvious pattern above.
Instead, look at the house of cards. Each row contains R cards leaning right, R cards leaning left, and each of the R
pairs of leaning cards has a horizontal card immediately above and to it's left, except for the right-most one. We could write this as
the equation
CR = R + R + (R - 1)
= 3R - 1.
So, in a house of cards with r rows, we need to add together the number of cards in each row from 1 up to and including r.
In symbols,
r
__
\
C = > (3R - 1)
/__
R = 1
If you're unfamiliar with the algebra of sum notation, you can read up on it here. Otherwise, the following steps should
be self-explanatory and I have deliberately moved one step at a time.
r
\
C = > (3R - 1)
/
R = 1
r
\
= > (3R) - r
/
R = 1
r
\
= 3 · > R - r
/
R = 1
/ r + 1 \
= 3r| ------- | - r [ Sum of the first N integers is ½n(n+1) ]
\ 2 /
3
= --- · r(r+1) - r.
2
Simplifying this final equation
We can do some straight-forward simplification of this equation, which is the same whatever
method we used so far. This leaves with a much tidier equation to finish.
3
C = --- · r(r+1) - r [Clear factor of r]
2
/ 3 \
= r | - · (r + 1) - 1 | [Multiply out those inner brackets]
\ 2 /
/ 3r 3 \
= r | -- + - - 1 |
\ 2 2 /
/ 3r 1 \
= r | -- + - |
\ 2 2 /
= ½r · (3r + 1)
And there you have it, in it's simplest form. I do hope that was informative.