aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-120/stuart-little/node/ch-1.js6
-rwxr-xr-xchallenge-120/stuart-little/node/ch-2.js10
2 files changed, 16 insertions, 0 deletions
diff --git a/challenge-120/stuart-little/node/ch-1.js b/challenge-120/stuart-little/node/ch-1.js
new file mode 100755
index 0000000000..9aa735004a
--- /dev/null
+++ b/challenge-120/stuart-little/node/ch-1.js
@@ -0,0 +1,6 @@
+#!/usr/bin/env node
+
+// run <script> <number>
+
+const binNr = (parseInt(process.argv[2]) & 255).toString(2).padStart(8,'0');
+console.log(parseInt([0,1,2,3].map(x => binNr.substr(2*x,2).split('').reverse().join('')).join(''),2))
diff --git a/challenge-120/stuart-little/node/ch-2.js b/challenge-120/stuart-little/node/ch-2.js
new file mode 100755
index 0000000000..8815b165e4
--- /dev/null
+++ b/challenge-120/stuart-little/node/ch-2.js
@@ -0,0 +1,10 @@
+#!/usr/bin/env node
+
+// run <script> <time>
+
+function angl(h,m) {
+ const rawDiff = Math.abs((h % 12)*30 + m/2 - m * 6);
+ return Math.min(rawDiff,360-rawDiff);
+}
+
+console.log(angl(...process.argv[2].split(':').map(x => parseInt(x))))