Pascal's Pyramid is an extension of Pascal's Triangle to the third dimension. Starting with a 1 as the apex, the elements of each successive layer can be determined by summing the three numbers that are above it. The nth layer contains the coefficients of (a + b + c)^n^(n-1)
.
You are to create a program that, given an input n, outputs the first n layers of Pascal's Pyramid. There must be two newlines between the different layers, and they must be in order. Within each layer, each row must be on a separate line, with the elements separated by spaces. Apart from that, you may format the pyramid however you like.
Your code should be reasonably fast generating a pyramid with 10 layers.
For example, your program, when given 4 as input, should output something like this:
1
1
1 1
1
2 2
1 2 1
1
3 3
3 6 3
1 3 3 1
May the shortest code win!