2023-12-09 10:01:24 +00:00
|
|
|
import sys
|
|
|
|
|
2023-12-09 11:36:03 +00:00
|
|
|
values = [int(c) for c in sys.stdin.read().strip().split(",")]
|
|
|
|
|
|
|
|
days = 256
|
|
|
|
lanterns = {day: 0 for day in range(days)}
|
|
|
|
for value in values:
|
|
|
|
for day in range(value, days, 7):
|
|
|
|
lanterns[day] += 1
|
|
|
|
|
|
|
|
for day in range(days):
|
|
|
|
for day2 in range(day + 9, days, 7):
|
|
|
|
lanterns[day2] += lanterns[day]
|
2023-12-09 10:01:24 +00:00
|
|
|
|
|
|
|
# part 1
|
2023-12-09 11:36:03 +00:00
|
|
|
answer_1 = sum(v for k, v in lanterns.items() if k < 80) + len(values)
|
2023-12-09 10:01:24 +00:00
|
|
|
print(f"answer 1 is {answer_1}")
|
|
|
|
|
|
|
|
# part 2
|
2023-12-09 11:36:03 +00:00
|
|
|
answer_2 = sum(lanterns.values()) + len(values)
|
2023-12-09 10:01:24 +00:00
|
|
|
print(f"answer 2 is {answer_2}")
|