5-01
This commit is contained in:
31
05/05-1.py
Normal file
31
05/05-1.py
Normal 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}")
|
||||
Reference in New Issue
Block a user