Solve day5

This commit is contained in:
2025-12-07 21:22:16 -08:00
parent 802506d860
commit 6aca754e5f
4 changed files with 1232 additions and 0 deletions

27
day5/part1.py Normal file
View 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())