Initial commit

This commit is contained in:
Geoffrey Frogeye 2024-12-25 12:58:02 +01:00
commit 97a4330bc0
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
110 changed files with 7006 additions and 0 deletions

28
2023/2/one.py Normal file
View file

@ -0,0 +1,28 @@
maxs = {"red": 12, "green": 13, "blue": 14}
gid = 0
possible_gid_sum = 0
with open("input") as lines:
for line in lines.readlines():
gid += 1
line = line.rstrip()
game_full, sets = line.split(":")
game, gid_str = game_full.split(" ")
assert int(gid_str) == gid
possible = True
for seet in sets.split(";"):
gcs = {"red": 0, "green": 0, "blue": 0}
for color in seet.split(","):
amount_str, color = color.strip().split(" ")
amount = int(amount_str)
gcs[color] += amount
for color, amount in gcs.items():
max = maxs[color]
if amount > max:
possible = False
if possible:
possible_gid_sum += gid
print(gid, possible)
print(possible_gid_sum)

24
2023/2/two.py Normal file
View file

@ -0,0 +1,24 @@
maxs = {"red": 12, "green": 13, "blue": 14}
gid = 0
power_sum = 0
with open("input") as lines:
for line in lines.readlines():
gid += 1
line = line.rstrip()
game_full, sets = line.split(":")
game, gid_str = game_full.split(" ")
assert int(gid_str) == gid
possible = True
gcs = {"red": 0, "green": 0, "blue": 0}
for seet in sets.split(";"):
for color in seet.split(","):
amount_str, color = color.strip().split(" ")
amount = int(amount_str)
gcs[color] = max(amount, gcs[color])
power = gcs["red"] * gcs["green"] * gcs["blue"]
print(gid, power)
power_sum += power
print(power_sum)