aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-05-10 16:51:35 -0400
committerchirvasitua <stuart-little@users.noreply.github.com>2021-05-10 16:51:35 -0400
commitee98b73a8ae2a80fe2109bd2f61dcf47119752c9 (patch)
treefcec882559e389e2fd2f34a01ae9909af6714f37
parent765d55c53dabebcd6b5832e3396e6d4fdcbb56e1 (diff)
downloadperlweeklychallenge-club-ee98b73a8ae2a80fe2109bd2f61dcf47119752c9.tar.gz
perlweeklychallenge-club-ee98b73a8ae2a80fe2109bd2f61dcf47119752c9.tar.bz2
perlweeklychallenge-club-ee98b73a8ae2a80fe2109bd2f61dcf47119752c9.zip
1st commit on 112_node
-rwxr-xr-xchallenge-112/stuart-little/node/ch-1.js7
-rwxr-xr-xchallenge-112/stuart-little/node/ch-2.js20
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-112/stuart-little/node/ch-1.js b/challenge-112/stuart-little/node/ch-1.js
new file mode 100755
index 0000000000..2feea0c4b4
--- /dev/null
+++ b/challenge-112/stuart-little/node/ch-1.js
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+// run <script> <path>
+
+const path = require('path');
+
+console.log(path.resolve(process.argv[2]))
diff --git a/challenge-112/stuart-little/node/ch-2.js b/challenge-112/stuart-little/node/ch-2.js
new file mode 100755
index 0000000000..d29b016779
--- /dev/null
+++ b/challenge-112/stuart-little/node/ch-2.js
@@ -0,0 +1,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));