# Beer Can Pyramid

talzamir
Posers and Puzzles 25 Sep '11 07:59
1. talzamir
Art, not a Toil
25 Sep '11 07:59
The fraternity really likes beer in cans. Over the years they've drunk lots and lots of it. Enough that they don't even remember exactly how many cans they've drunk. They know that there are at least one million empty cans in their backyard, and decide to invest in a new backyard when the number hits two million, but they are not quite there yet. In the meanwhile they decide to tidy up and make a neat pyramid of the cans. After some planning they decide that the pyramid can be "aztec style" with a flat top, high or low as long as it is not just a row of cans, and it can't have a jagged top as that would be "uncool". To get the job done, they pledge to drink no more beer until the job is done.. and try and try.. and finally find out that with the number of cans they have, the job is impossible.

How many cans of beer do they have?

(which, without the flavor text, is the same as, show that there is exactly one integer between 1,000,000 and 2,000,000 that can't be expressed as a sum of two or more consequtive natural numbers and find out what it is.

For example,
1,000,000 = 199,998 + 199,999 + 200,000 + 200,001 + 200,002,
1,000,001 = 500,000 + 500,001
1,000,002 = 333,333 + 333,334 + 333,335
etc.
but going all the way to 2 million by brute force is not elegant and could take a while.)
2. talzamir
Art, not a Toil
02 Oct '11 10:36
Solution.

If the pyramid had a sharp top, there would be 1 + 2+ ... + n cans where n is the number of layers, so n >= 2. That's an arithmetic sequence, equal to n (n + 1) / 2. Each such pyramid can be adjusted by adding the same number of cans to each layer, giving the flat-top pyramids. Adding k cans to each layer means adding k times n cans total, so the number of cans in the pyramid is

n (n + 1) / 2 + kn = n (n +1) / 2 + 2nk / 2 = n (n + 1 + 2k) / 2.

n is either even or odd. If it is even, then n + 2k + 1 is odd. Therefore the the number of cans is always divisible by some odd number equal to 3 or more, as n is at least 2 and n + 1 + 2k is more than n. That means that it is impossible to create a pyramid that isn't divisible by any odd number equal to 3 or more. One of these is the solution; 2^20 = 1,048,576.

All the rest of the numbers have an odd factor, p. For such a number there is a solution consisting of p consequent integers. If the number is q times p for some q, then

(a + 1) + (a + 2) + ... +(a + p) = ap + p(p + 1) / 2 = p(2a + p + 1) / 2

so (2a + p + 1) /2 needs to equal q. As changing the value of a by 1 changes the value of (2a + p + 1)/2 by one, it is clear that the expression can get all possible integers as value. The number needed is at least 1, for odd primes.

(2a + p + 1) / 2 >= 1
2a + p + 1 >= 2
a >= (1 - p)/2

which means that there are at least two positive values in the sequence, so when the positive and number numbers cancel have cancelled out, what is left is valid solution. For example, 9 has odd factors above 1, 3 and 9;
based on 3; 9 / 3 = 3; three numbers around 3. 2+3+4 = 9
based on 9; 9 / 9 = 1; nine numbers around 1. (-3)+(-2)+ .. + 4 + 5 = 4 + 5 = 9.
3. 02 Oct '11 16:514 edits
Hmm, what is the most interesting shape they *can* make?

The most interesting shape they *can't* make is probably a 4d cube, 32 to a side.

Can we beat two triangular 3d pyramids?
4. talzamir
Art, not a Toil
03 Oct '11 08:00
Depends on one's sense of aesthetics, and in case of dimensions above three, possibly on the kind of hallucinations one has.. a cube of 20 dimensions with two cans on a side, requires some really, really groovy beer. It makes all sorts of boxes that should look really cool for a Borg.

My favorite atm would be a box with five dimensions, measuring 4 x 8 x 16 x 32 x 64. While the numbers are not in sequence, they become so if taken a base 2 logarithm, making it the closest approximation to a flat-top pyramid I can find.