32 lines
756 B
Python
32 lines
756 B
Python
#!/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}")
|