MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
###Explanation
Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc. Concatenating these arrays vertically and computing the sum of each column gives the result.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.
MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
###Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc. Concatenating these arrays vertically and computing the sum of each column gives the result.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.
MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc. Concatenating these arrays vertically and computing the sum of each column gives the result.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.
MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
###Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc. Concatenating these arrays vertically and computing the sum of each column gives the result.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.
MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
###Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.
MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
###Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc. Concatenating these arrays vertically and computing the sum of each column gives the result.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.
MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
###Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.
MATL, 16 bytes
tZv=Gq:"t5BZ+]vs
###Explanation
This repeatedly applies convolution to generate the rows. For example, for input n=5 we start with the first row
0 0 0 0 1 0 0 0 0
Convolving with [1 0 1] gives
0 0 0 1 0 1 0 0 0
Repeating the operation gives
0 0 1 0 2 0 1 0 0
then
0 1 0 3 0 3 0 1 0
etc.
t % Input n implictly. Duplicate
Zv % Symmetric range. Gives [1 2 3 4 5 4 3 2 1] for input 5
= % Equal to (element-wise). Gives [0 0 0 0 1 0 0 0 0]. This is the first row
Gq: % Push [1 2 ... n-1]
" % For each. This executes the following code n-1 times
t % Duplicate
5B % Push 5 in binary, that is, [1 0 1]
Z+ % Convolution keeping size
] % End
v % Concatenate all results vertically
s % Sum. Display implicitly.