aboutsummaryrefslogtreecommitdiff
path: root/challenge-112/stuart-little/node/ch-2.js
blob: d29b01677924fe0caef578521caf20a6192212fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env node

// run <script> <number>

let memo = [
    [[1,],],
    [[1,1],[2,]],
];

function memoSteps(n) {
    if (typeof(memo[n]) === 'undefined') {
	memo[n] = [...(memoSteps(n-1).map(x => [1,...x])) , ...(memoSteps(n-2).map(x => [2,...x]))];
    }
    return memo[n]
}

const res = memoSteps(parseInt(process.argv[2])-1);
console.log(`${res.length}
${"-".repeat(12)}`);
res.forEach(x => console.log(x));