diff options
Diffstat (limited to 'challenge-146/abigail/node')
| -rw-r--r-- | challenge-146/abigail/node/ch-1.js | 11 | ||||
| -rw-r--r-- | challenge-146/abigail/node/ch-2.js | 31 |
2 files changed, 42 insertions, 0 deletions
diff --git a/challenge-146/abigail/node/ch-1.js b/challenge-146/abigail/node/ch-1.js new file mode 100644 index 0000000000..51ce680b89 --- /dev/null +++ b/challenge-146/abigail/node/ch-1.js @@ -0,0 +1,11 @@ +#!/usr/local/bin/node + +// +// See ../README.md +// + +// +// Run as: node ch-1.js +// + +console . log ("104743")
\ No newline at end of file diff --git a/challenge-146/abigail/node/ch-2.js b/challenge-146/abigail/node/ch-2.js new file mode 100644 index 0000000000..ce7fba74c7 --- /dev/null +++ b/challenge-146/abigail/node/ch-2.js @@ -0,0 +1,31 @@ +#!/usr/local/bin/node + +// +// See ../README.md +// + +// +// Run as: node ch-2.js < input-file +// + + require ('readline') +. createInterface ({input: process . stdin}) +. on ('line', line => { + let [a, b] = line . trim () . split ("/") . map (x => +x) + for (let i = 1; i <= 2; i ++) { + if (a < b) { + b -= a + } + else { + a -= b + } + if (a == 0 || b == 0) { + break + } + process . stdout . write (a . toString ()) + process . stdout . write ("/") + process . stdout . write (b . toString ()) + process . stdout . write (" ") + } + process . stdout . write ("\n") +}) |
