add: day05: part1
This commit is contained in:
24
2025/day05/part1.py
Normal file
24
2025/day05/part1.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
text: str
|
||||||
|
|
||||||
|
with open("input.txt") as f:
|
||||||
|
text = f.read()
|
||||||
|
|
||||||
|
total: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
ranges_str, dates = text.split("\n\n")
|
||||||
|
|
||||||
|
ranges: list[tuple[int, int]] = []
|
||||||
|
for range_str in ranges_str.splitlines():
|
||||||
|
start, stop = range_str.split("-")
|
||||||
|
ranges.append((int(start), int(stop)))
|
||||||
|
|
||||||
|
dates: list[int] = [int(date) for date in dates.splitlines()]
|
||||||
|
dates.sort()
|
||||||
|
|
||||||
|
for date in dates:
|
||||||
|
for start, stop in ranges:
|
||||||
|
if (start <= date <= stop):
|
||||||
|
total += 1
|
||||||
|
break
|
||||||
|
print(total)
|
||||||
Reference in New Issue
Block a user