Some checks reported errors
continuous-integration/drone/push Build encountered an error
34 lines
No EOL
725 B
Python
34 lines
No EOL
725 B
Python
#!/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}") |