-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpart-two.js
30 lines (25 loc) · 1.09 KB
/
part-two.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const { SUES, TICKER_TAPE } = require('./input');
let possible_aunts = SUES.filter(aunt => {
for (let quality in aunt) {
if (quality === 'number') continue;
// The `cats` and `trees` readings indicates that there are _greater than_ that many
if (quality === 'cats' || quality === 'trees') {
// If they have to be _greater than_ the ticker readings, exit if we are _less than or equal_
if (aunt[quality] <= TICKER_TAPE[quality]) {
return false;
}
// The `pomeranians` and `goldfish` readings indicate that there are _fewer than_ that many
} else if (quality === 'pomeranians' || quality === 'goldfish') {
// If they have to be _fewer than_ the ticker readings, exit if we are _greater than or equal_
if (aunt[quality] >= TICKER_TAPE[quality]) {
return false;
}
} else {
if (TICKER_TAPE[quality] !== aunt[quality]) {
return false;
}
}
}
return true;
});
console.log(possible_aunts[0].number);