We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6e0f2fb commit fb2c9e5Copy full SHA for fb2c9e5
day6/index.js
@@ -13,12 +13,17 @@ export const part1 = ({ input }) => {
13
};
14
15
export const part2 = ({ input }) => {
16
+ const time = parseInt(input[0].replace(/\D/g, ""));
17
+ const record = parseInt(input[1].replace(/\D/g, ""));
18
+
19
let result = 0;
- const time = input[0].replace(/\D/g, "");
- const record = input[1].replace(/\D/g, "");
20
- const distances = calculateDistances(time);
21
- result = distances.filter((distance) => distance.distance > record).length;
+ for (let i = 0; i < time; i++) {
22
+ const distance = i * (time - i);
23
+ if (distance > record) {
24
+ result++;
25
+ }
26
27
28
return result;
29
0 commit comments