diff --git a/2023/day02/example2.txt b/2023/day02/example2.txt new file mode 100644 index 0000000..1cd7d33 --- /dev/null +++ b/2023/day02/example2.txt @@ -0,0 +1,5 @@ +Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green +Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue +Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red +Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red +Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green \ No newline at end of file diff --git a/2023/day02/src/part2.py b/2023/day02/src/part2.py new file mode 100644 index 0000000..087ec3e --- /dev/null +++ b/2023/day02/src/part2.py @@ -0,0 +1,18 @@ +text: str = open("input.txt", "r").read() + +import math + +value: int = 0 + +for line in text.split("\n"): + ok = 0 + game = line.split(": ") + bozo_dict: dict = {} + for bozo_set in game[1].split("; "): + for cube in bozo_set.split(", "): + values = cube.split(" ") + if (bozo_dict.get(values[1], 0) < int(values[0])): + bozo_dict.update({values[1]: int(values[0])}) + value += math.prod(bozo_dict.values()) + +print(value) \ No newline at end of file