This commit is contained in:
2025-12-05 19:50:35 +01:00
parent d7fa2225d9
commit 53e850b5df
3 changed files with 1225 additions and 0 deletions

31
05/05-1.py Normal file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#file = "./ex.txt"
file = "./input.txt"
if __name__ == "__main__":
solution = 0
ingredients = []
fresh_ranges = []
input_file = open(file, "r")
for line in input_file:
line = line.strip()
if line == "":
continue
elif "-" in line:
a,b = line.split('-')
a = int(a)
b = int(b)
fresh_ranges.append([a,b])
else:
ingredients.append(int(line))
for i in ingredients:
is_in_range = False
for r in fresh_ranges:
if i in range(r[0],r[1]+1):
is_in_range = True
if is_in_range:
solution += 1
print(f"Solution: {solution}")