Day 6: optimize q2 by starting from q1 answer

This commit is contained in:
Alice Gaudon 2020-12-06 14:10:21 +01:00
parent 6a406103bb
commit 30c04711c9
1 changed files with 2 additions and 4 deletions

View File

@ -19,13 +19,11 @@ fs.readFile('input.txt', (err, data) => {
if (q1Questions.indexOf(question) < 0) {
q1Questions.push(question);
}
if (q2Questions.indexOf(question) < 0 && group.every(person => person.indexOf(question) >= 0)) {
q2Questions.push(question);
}
}
}
q2Questions = q1Questions.filter(question => group.every(person => person.indexOf(question) >= 0));
q1 += q1Questions.length;
q2 += q2Questions.length;
}