2023-12-28 04:02:59 +01:00
|
|
|
from lib import *
|
2023-12-04 00:05:09 +01:00
|
|
|
|
2023-12-28 04:02:59 +01:00
|
|
|
def solve(input: Input, second=False):
|
|
|
|
ps = input.text.split("\n\n")
|
|
|
|
xss = map(lambda p: map(int, p.splitlines()), ps)
|
|
|
|
xs = list(map(sum, xss))
|
|
|
|
if not second:
|
|
|
|
return max(xs)
|
|
|
|
xs.sort()
|
|
|
|
return sum(xs[-3:])
|
2023-12-04 00:05:09 +01:00
|
|
|
|
|
|
|
def main():
|
2023-12-28 04:02:59 +01:00
|
|
|
DAY_INPUT = "i1.txt"
|
|
|
|
print("Solution 1:", solve(Input(DAY_INPUT)))
|
|
|
|
assert solve(Input(DAY_INPUT)) == 69883
|
|
|
|
print("Solution 2:", solve(Input(DAY_INPUT), True))
|
|
|
|
assert solve(Input(DAY_INPUT), True) == 207576
|
2023-12-04 00:05:09 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|