diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-07-05 23:00:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-05 23:00:18 +0100 |
| commit | 90d31f3b2306f5a69d655cedf6aeed381758a98f (patch) | |
| tree | 84e893bf79424b44bfba06bf5861baeb201ba342 | |
| parent | c8972701c0cc77c3b5c2cc9acd359c0bb291196e (diff) | |
| parent | 9aab8026549afa45f025e83f0858d0c9ab88f129 (diff) | |
| download | perlweeklychallenge-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-x | challenge-120/stuart-little/node/ch-1.js | 6 | ||||
| -rwxr-xr-x | challenge-120/stuart-little/node/ch-2.js | 10 |
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)))) |
