-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03.ts
37 lines (34 loc) · 891 Bytes
/
03.ts
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
31
32
33
34
35
36
37
import Task, { TaskPartSolution } from "../utils/task.js";
const part1: TaskPartSolution = (input) => {
return input.split("\n").filter((r) => {
const [a, b, c] = r.trim().split(/\W+/).map(Number);
return a + b > c && a + c > b && c + b > a;
}).length;
};
const part2: TaskPartSolution = (input) => {
const numbers = input.split("\n").flatMap((r) => {
return r.trim().split(/\W+/).map(Number);
});
let valid = 0;
while (numbers.length > 0) {
const mx = numbers.splice(0, 9);
for (let index = 0; index < 3; index++) {
const [a, b, c] = [mx[index], mx[index + 3], mx[index + 6]];
if (a + b > c && a + c > b && b + c > a) {
valid += 1;
}
}
}
return valid;
};
const task = new Task(2016, 3, part1, part2, {
part1: {
input: ``,
result: "",
},
part2: {
input: ``,
result: "",
},
});
export default task;