Day 6: optimize q2 by starting from q1 answer
This commit is contained in:
parent
6a406103bb
commit
30c04711c9
@ -19,12 +19,10 @@ fs.readFile('input.txt', (err, data) => {
|
|||||||
if (q1Questions.indexOf(question) < 0) {
|
if (q1Questions.indexOf(question) < 0) {
|
||||||
q1Questions.push(question);
|
q1Questions.push(question);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (q2Questions.indexOf(question) < 0 && group.every(person => person.indexOf(question) >= 0)) {
|
q2Questions = q1Questions.filter(question => group.every(person => person.indexOf(question) >= 0));
|
||||||
q2Questions.push(question);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
q1 += q1Questions.length;
|
q1 += q1Questions.length;
|
||||||
q2 += q2Questions.length;
|
q2 += q2Questions.length;
|
||||||
|
Loading…
Reference in New Issue
Block a user