diff options
Diffstat (limited to 'challenge-195/roger-bell-west/javascript/ch-1.js')
| -rwxr-xr-x | challenge-195/roger-bell-west/javascript/ch-1.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/challenge-195/roger-bell-west/javascript/ch-1.js b/challenge-195/roger-bell-west/javascript/ch-1.js new file mode 100755 index 0000000000..728340ef1c --- /dev/null +++ b/challenge-195/roger-bell-west/javascript/ch-1.js @@ -0,0 +1,37 @@ +#! /usr/bin/node + +"use strict" + +function specialintegers(n) { + let o = 0; + for (let i = 1; i <= n; i++) { + let f = new Set(); + let s = true; + for (let c of i.toString()) { + if (f.has(c)) { + s = false; + break; + } else { + f.add(c); + } + } + if (s == 1) { + o++; + } + } + return o; +} + +if (specialintegers(15) == 14) { + process.stdout.write("Pass"); +} else { + process.stdout.write("FAIL"); +} +process.stdout.write(" "); + +if (specialintegers(35) == 32) { + process.stdout.write("Pass"); +} else { + process.stdout.write("FAIL"); +} +process.stdout.write("\n"); |
