Solve day5
This commit is contained in:
27
day5/part1.py
Normal file
27
day5/part1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
FILE = "input.txt"
|
||||
|
||||
def main():
|
||||
freshRanges = []
|
||||
indgredients = []
|
||||
complete = False
|
||||
for line in open(FILE):
|
||||
if line == "\n":
|
||||
complete = True
|
||||
continue
|
||||
if not complete:
|
||||
freshRanges.append(line.strip().split("-"))
|
||||
else:
|
||||
indgredients.append(line.strip())
|
||||
freshRanges = [
|
||||
range(int(start), int(stop)+1) for (start, stop) in freshRanges
|
||||
]
|
||||
indgredients = [ int(x) for x in indgredients ]
|
||||
return len([
|
||||
indgredient
|
||||
for indgredient in indgredients
|
||||
if any(indgredient in r for r in freshRanges)
|
||||
])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(main())
|
||||
Reference in New Issue
Block a user