diff options
| author | Abigail <abigail@abigail.be> | 2021-07-28 15:53:40 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-07-28 16:09:38 +0200 |
| commit | bd9797e1d52dc5b0853bc5400f04f477ffd6a4cb (patch) | |
| tree | 576c67d4bd3635f7a11b78180d4c569eabd167ea /challenge-123/abigail/node | |
| parent | e604addad68c72201f22c43a611787e06983d7e9 (diff) | |
| download | perlweeklychallenge-club-bd9797e1d52dc5b0853bc5400f04f477ffd6a4cb.tar.gz perlweeklychallenge-club-bd9797e1d52dc5b0853bc5400f04f477ffd6a4cb.tar.bz2 perlweeklychallenge-club-bd9797e1d52dc5b0853bc5400f04f477ffd6a4cb.zip | |
Solutions in 15 languages for week 123, part 2.
Diffstat (limited to 'challenge-123/abigail/node')
| -rw-r--r-- | challenge-123/abigail/node/ch-2.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-123/abigail/node/ch-2.js b/challenge-123/abigail/node/ch-2.js new file mode 100644 index 0000000000..85ec5ce186 --- /dev/null +++ b/challenge-123/abigail/node/ch-2.js @@ -0,0 +1,22 @@ +#!/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 [x1, y1, x2, y2, x3, y3, x4, y4] = line . split (/ +/) . map (_ => +_) + let e1 = (x1 - x2) ** 2 + (y1 - y2) ** 2 + let e2 = (x2 - x3) ** 2 + (y2 - y3) ** 2 + let e3 = (x3 - x4) ** 2 + (y3 - y4) ** 2 + let e4 = (x4 - x1) ** 2 + (y4 - y1) ** 2 + let d1 = (x1 - x3) ** 2 + (y1 - y3) ** 2 + let d2 = (x2 - x4) ** 2 + (y2 - y4) ** 2 + console . log (e1 == e2 && e2 == e3 && e3 == e4 && d1 == d2 ? 1 : 0) +}) |
