solved day 5, part 1!

brechtje
Brechtje van Gessel 2025-12-05 11:26:21 +01:00
parent e300e71e8a
commit 4e20ede3d1
1 changed files with 19 additions and 0 deletions

19
brechtje/5/5-1.py Normal file
View File

@ -0,0 +1,19 @@
input = open('input.txt', 'r').read().splitlines()
ranges = []
food = []
answer = 0
for line in input:
if '-' in line:
ranges.append(list(map(int, line.split('-'))))
elif line != '':
food.append(int(line))
for item in food:
for range in ranges:
if range[0] <= item <= range[1]:
answer += 1
break
print(answer)