summaryrefslogtreecommitdiffstats
path: root/day6/day6-2.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <piotr.russ@betvictor.com> 2020-12-09 23:45:11 +0100
committerGravatar Piotr Russ <piotr.russ@betvictor.com> 2020-12-09 23:45:11 +0100
commitcbbdf1c07d629d2947659768110ccf2a6dc5066b (patch)
treeb2cdccbaf9dff76adbfc2b5d2395028ea6440948 /day6/day6-2.js
parent02cfa242c714d25a60151f0629418298432765eb (diff)
downloadadvent_of_code_2020-cbbdf1c07d629d2947659768110ccf2a6dc5066b.tar.gz
advent_of_code_2020-cbbdf1c07d629d2947659768110ccf2a6dc5066b.tar.bz2
advent_of_code_2020-cbbdf1c07d629d2947659768110ccf2a6dc5066b.zip
day6
Diffstat (limited to 'day6/day6-2.js')
-rw-r--r--day6/day6-2.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/day6/day6-2.js b/day6/day6-2.js
new file mode 100644
index 0000000..965312d
--- /dev/null
+++ b/day6/day6-2.js
@@ -0,0 +1,9 @@
+const data = require('./data')
+
+const repeats = data
+ .split(/\n{2,}/g)
+ .map(g => g.replace(/(^\n)|(\n$)/g,'').split('\n').map(s => s.split('')))
+ .map(g => g[0].map(s => g.every(a => a.includes(s))).filter(x => x === true).length)
+ .reduce((a, b) => a + b, 0)
+
+console.log(repeats)