5 saved 2 bytes
source | link

JavaScript (ES6), 90 87 86 8484 82 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=a)=>n--?f(n,[...(F=(x,d)=>aF=x=>a.map((n,i)=>n+~~x[i-d]))(a,2d=2),0,1]d=1],F(b,1)):b

Test cases

f=(n,a=[1],b=a)=>n--?f(n,[...(F=(x,d)=>aF=x=>a.map((n,i)=>n+~~x[i-d]))(a,2d=2),0,1]d=1],F(b,1)):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

JavaScript (ES6), 90 87 86 84 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=a)=>n--?f(n,[...(F=(x,d)=>a.map((n,i)=>n+~~x[i-d]))(a,2),0,1],F(b,1)):b

Test cases

f=(n,a=[1],b=a)=>n--?f(n,[...(F=(x,d)=>a.map((n,i)=>n+~~x[i-d]))(a,2),0,1],F(b,1)):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

JavaScript (ES6), 90 87 86 84 82 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=a)=>n--?f(n,[...(F=x=>a.map((n,i)=>n+~~x[i-d]))(a,d=2),0,d=1],F(b)):b

Test cases

f=(n,a=[1],b=a)=>n--?f(n,[...(F=x=>a.map((n,i)=>n+~~x[i-d]))(a,d=2),0,d=1],F(b)):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

4 saved 2 bytes
source | link

JavaScript (ES6), 90 87 8686 84 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=a)=>n--?f(n,[...a(F=(x,d)=>a.map((n,i)=>n+~~a[i=>n+~~x[i-2]d]))(a,2),0,1],a.map(F(nb,i)=>n+~~b[i-1]1)):b

Test cases

f=(n,a=[1],b=a)=>n--?f(n,[...a(F=(x,d)=>a.map((n,i)=>n+~~a[i=>n+~~x[i-2]d]))(a,2),0,1],a.map(F(nb,i)=>n+~~b[i-1]1)):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

JavaScript (ES6), 90 87 86 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=a)=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

Test cases

f=(n,a=[1],b=a)=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

JavaScript (ES6), 90 87 86 84 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=a)=>n--?f(n,[...(F=(x,d)=>a.map((n,i)=>n+~~x[i-d]))(a,2),0,1],F(b,1)):b

Test cases

f=(n,a=[1],b=a)=>n--?f(n,[...(F=(x,d)=>a.map((n,i)=>n+~~x[i-d]))(a,2),0,1],F(b,1)):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

3 saved 1 byte
source | link

JavaScript (ES6), 90 8787 86 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=[]b=a)=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

Test cases

f=(n,a=[1],b=[]b=a)=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

JavaScript (ES6), 90 87 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=[])=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

Test cases

f=(n,a=[1],b=[])=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

JavaScript (ES6), 90 87 86 bytes

Saved 3 bytes thanks to ETHproductions

f=(n,a=[1],b=a)=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

Test cases

f=(n,a=[1],b=a)=>n--?f(n,[...a.map((n,i)=>n+~~a[i-2]),0,1],a.map((n,i)=>n+~~b[i-1])):b

console.log(JSON.stringify(f(1)))
console.log(JSON.stringify(f(2)))
console.log(JSON.stringify(f(3)))
console.log(JSON.stringify(f(5)))
console.log(JSON.stringify(f(11)))

2 added 48 characters in body
source | link
1
source | link