diff options
| author | Dave Jacoby <jacoby.david@gmail.com> | 2021-06-28 15:58:12 -0400 |
|---|---|---|
| committer | Dave Jacoby <jacoby.david@gmail.com> | 2021-06-28 15:58:12 -0400 |
| commit | b61107f1bb11bbca80bbda7c0f9a63221eec1bbe (patch) | |
| tree | dd24c28fbb1e5871c394e8d6b8db7bf3d5dd0db1 /challenge-119/dave-jacoby/node/ch-1.js | |
| parent | 6856b37c0c18ff1c8a330db9be7dcfd41d6ab9a1 (diff) | |
| download | perlweeklychallenge-club-b61107f1bb11bbca80bbda7c0f9a63221eec1bbe.tar.gz perlweeklychallenge-club-b61107f1bb11bbca80bbda7c0f9a63221eec1bbe.tar.bz2 perlweeklychallenge-club-b61107f1bb11bbca80bbda7c0f9a63221eec1bbe.zip | |
All but Blogging
Diffstat (limited to 'challenge-119/dave-jacoby/node/ch-1.js')
| -rw-r--r-- | challenge-119/dave-jacoby/node/ch-1.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-119/dave-jacoby/node/ch-1.js b/challenge-119/dave-jacoby/node/ch-1.js new file mode 100644 index 0000000000..6d1075d34d --- /dev/null +++ b/challenge-119/dave-jacoby/node/ch-1.js @@ -0,0 +1,23 @@ +"use strict"; + +for (let i in Array(21).fill("")) { + let v = flopped(i); + console.log(["", i, v].join("\t")); +} + +console.log(["", 86, flopped(86)].join("\t")); +console.log(["", 101, flopped(101)].join("\t")); +console.log(["", 18, flopped(18)].join("\t")); +console.log(["", 33, flopped(33)].join("\t")); + +function flopped(n) { + let b = parseInt(n).toString(2); + while (b.length < 8) { + b = "0" + b; + } + let front = b.substring(0, 4); + let back = b.substring(4); + let r = back + front; + let x = parseInt(r, 2); + return x; +} |
