aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-05-11 09:39:54 +0100
committerGitHub <noreply@github.com>2021-05-11 09:39:54 +0100
commit83385ff8b417180e0b715f73cf41287ac3c3037b (patch)
tree5909683fd81331d1ee73a4b9e113262d1fd5fa07
parent39fc6387340142805e16ddb5b22dff42a14d840b (diff)
parentee98b73a8ae2a80fe2109bd2f61dcf47119752c9 (diff)
downloadperlweeklychallenge-club-83385ff8b417180e0b715f73cf41287ac3c3037b.tar.gz
perlweeklychallenge-club-83385ff8b417180e0b715f73cf41287ac3c3037b.tar.bz2
perlweeklychallenge-club-83385ff8b417180e0b715f73cf41287ac3c3037b.zip
Merge pull request #4058 from stuart-little/stuart-little_112_node
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));