AdventOfCode2020/day_6/task_1.js
2020-12-06 17:54:51 +01:00

17 lines
403 B
JavaScript

const fs = require('fs');
const file = fs.readFileSync(__dirname + '/input.txt').toString('utf-8');
const groups = file.split('\n\n');
let total = 0;
groups.forEach(answers => {
answers = answers
.replace(/\n/g, '')
.split('');
let answered = {};
answers.forEach(a => answered[a] = true);
total += Object.keys(answered).length;
});
console.log(`Total: ${total}`);