aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-07-05 23:00:18 +0100
committerGitHub <noreply@github.com>2021-07-05 23:00:18 +0100
commit90d31f3b2306f5a69d655cedf6aeed381758a98f (patch)
tree84e893bf79424b44bfba06bf5861baeb201ba342
parentc8972701c0cc77c3b5c2cc9acd359c0bb291196e (diff)
parent9aab8026549afa45f025e83f0858d0c9ab88f129 (diff)
downloadperlweeklychallenge-club-90d31f3b2306f5a69d655cedf6aeed381758a98f.tar.gz
perlweeklychallenge-club-90d31f3b2306f5a69d655cedf6aeed381758a98f.tar.bz2
perlweeklychallenge-club-90d31f3b2306f5a69d655cedf6aeed381758a98f.zip
Merge pull request #4433 from stuart-little/stuart-little_120_node
1st commit on 120_node
-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))))