2025 - Day 5 part 1
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
kleph 2025-12-05 18:33:17 +01:00
parent bea0c5acef
commit c4da98da4b
3 changed files with 1232 additions and 0 deletions

34
2025/5/5.py Normal file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env python
# 2025 - Advent Of Code 5
# file = 'input_example.txt'
file = 'input.txt'
# pylint: disable=consider-using-with
input_lines = [line.strip('\n') for line in open(file, encoding="utf-8")]
ranges = []
ingredients = []
ingredient = 0
for line in input_lines:
if ingredient == 0:
if not line:
ingredient = 1
continue
else:
ranges.append(line.split('-'))
else:
ingredients.append(int(line))
print(ranges)
print(ingredients)
fresh = 0
for i in ingredients:
for r in ranges:
if int(r[0]) <= i <= int(r[1]):
print(f"{i} is fresh")
fresh += 1
break
print(f"Total fresh ingredients: {fresh}")

1187
2025/5/input.txt Normal file

File diff suppressed because it is too large Load diff

11
2025/5/input_example.txt Normal file
View file

@ -0,0 +1,11 @@
3-5
10-14
16-20
12-18
1
5
8
11
17
32