diff --git a/2025-python/output/day_05.py b/2025-python/output/day_05.py new file mode 100644 index 0000000..eda70e6 --- /dev/null +++ b/2025-python/output/day_05.py @@ -0,0 +1,31 @@ +from output import ints + + +def solve(data): + p1 = None + p2 = 0 + ranges, ids = data.split("\n\n") + ids = ints(ids) + R = [ints(line) for line in ranges.split()] + p1 = sum(any(s <= n <= e for s, e in R) for n in ids) + c = 0 + for s, e in sorted(R): + s = max(c + 1, s) + if s <= e: + p2 += e - s + 1 + c = max(e, c) + + return p1, p2 + + +if __name__ == "__main__": + with open("./input/05.txt", "r") as f: + inp = f.read().strip() + + p1, p2 = solve(inp) + + print(p1) + print(p2) + + assert p1 == 509 + assert p2 == 336790092076620