Initial commit.
This commit is contained in:
commit
a57192c723
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
venv
|
19
2022/day1.py
Normal file
19
2022/day1.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
with open(Path(__file__).parent.joinpath("inputs", "day1.txt")) as fp:
|
||||||
|
lines = fp.readlines()
|
||||||
|
|
||||||
|
values: list[int] = [0]
|
||||||
|
for line in lines:
|
||||||
|
if not line.strip():
|
||||||
|
values = values + [0]
|
||||||
|
else:
|
||||||
|
values[-1] += int(line.strip())
|
||||||
|
|
||||||
|
# part 1
|
||||||
|
print(f"max is {max(values)}")
|
||||||
|
|
||||||
|
# part 2
|
||||||
|
print(f"sum of top 3 is {sum(sorted(values)[-3:])}")
|
2251
2022/inputs/day1.txt
Normal file
2251
2022/inputs/day1.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user