aboutsummaryrefslogtreecommitdiff
path: root/challenge-087/abigail/node
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2020-11-17 19:48:58 +0100
committerAbigail <abigail@abigail.be>2020-11-17 19:48:58 +0100
commitcbf05bb5a4475880c502d05e756c5398e24beb23 (patch)
tree1b67750792920f468685c051694170a41513a2ab /challenge-087/abigail/node
parent0abb7247c49189d64f025add7f1b7868505e1e8b (diff)
downloadperlweeklychallenge-club-cbf05bb5a4475880c502d05e756c5398e24beb23.tar.gz
perlweeklychallenge-club-cbf05bb5a4475880c502d05e756c5398e24beb23.tar.bz2
perlweeklychallenge-club-cbf05bb5a4475880c502d05e756c5398e24beb23.zip
Tiny improvements
Diffstat (limited to 'challenge-087/abigail/node')
-rw-r--r--challenge-087/abigail/node/ch-1.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/challenge-087/abigail/node/ch-1.js b/challenge-087/abigail/node/ch-1.js
index ffb0022caa..e439a5b847 100644
--- a/challenge-087/abigail/node/ch-1.js
+++ b/challenge-087/abigail/node/ch-1.js
@@ -29,13 +29,13 @@
//
// Read STDIN. Split on newlines, then on whitespace, and turn the results
-// into numbers. Since the input will be newline terminated, we have an
-// empty line to filter out.
+// into numbers.
//
let lines = require ("fs")
. readFileSync (0) // Read all.
. toString () // Turn it into a string.
- . split ("\n"); // Split on newlines.
+ . split ("\n") // Split on newlines.
+;
//
@@ -53,11 +53,10 @@ for (let i = 0; i < lines . length - 1; i ++) {
}, {});
let best = [0, 0];
- INNER:
for (let i = 0; i < array . length; i ++) {
let low = array [i];
if (!set [low]) {
- continue INNER; // Skip if it's no longer in the set.
+ continue; // Skip if it's no longer in the set.
}
let high = low;
while (set [low - 1]) {
@@ -74,6 +73,10 @@ for (let i = 0; i < lines . length - 1; i ++) {
set [i] = 0;
}
}
+
+ //
+ // Output
+ //
let str = "";
for (let i = best [0]; i <= best [1]; i ++) {
str += i;