aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-07-05 08:59:37 -0400
committerchirvasitua <stuart-little@users.noreply.github.com>2021-07-05 08:59:37 -0400
commit9aab8026549afa45f025e83f0858d0c9ab88f129 (patch)
treecd45cda91254176db68c0a25fd0de90b924f4267
parentd5f2a0c9f3ee311ab8e8d14f6cb67efbc01250ec (diff)
downloadperlweeklychallenge-club-9aab8026549afa45f025e83f0858d0c9ab88f129.tar.gz
perlweeklychallenge-club-9aab8026549afa45f025e83f0858d0c9ab88f129.tar.bz2
perlweeklychallenge-club-9aab8026549afa45f025e83f0858d0c9ab88f129.zip
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))))