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 a95c406 commit fb95f33Copy full SHA for fb95f33
day2/index.js
@@ -23,7 +23,28 @@ export const part1 = ({ input }) => {
23
};
24
25
export const part2 = ({ input }) => {
26
- const result = 0;
+ let result = 0;
27
+ input.forEach((row) => {
28
+ const { hands } = splitInput({ row });
29
+ let blue = 0;
30
+ let green = 0;
31
+ let red = 0;
32
+
33
+ hands.forEach((hand) => {
34
+ if (hand.hasOwnProperty("blue") && hand.blue > blue) {
35
+ blue = hand.blue;
36
+ }
37
+ if (hand.hasOwnProperty("green") && hand.green > green) {
38
+ green = hand.green;
39
40
+ if (hand.hasOwnProperty("red") && hand.red > red) {
41
+ red = hand.red;
42
43
+ });
44
45
+ const power = green * red * blue;
46
+ result += power;
47
48
return result;
49
50
0 commit comments