2022 day 1
This commit is contained in:
2267
2022/01/input
Normal file
2267
2022/01/input
Normal file
File diff suppressed because it is too large
Load Diff
23
2022/01/part1
Executable file
23
2022/01/part1
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
elves = []
|
||||||
|
|
||||||
|
with open('input') as f:
|
||||||
|
elf = []
|
||||||
|
for line in f:
|
||||||
|
if line == "\n":
|
||||||
|
elves.append(elf)
|
||||||
|
elf = []
|
||||||
|
else:
|
||||||
|
calories = int(line)
|
||||||
|
elf.append(calories)
|
||||||
|
|
||||||
|
most = 0
|
||||||
|
|
||||||
|
for elf in elves:
|
||||||
|
calories = sum(elf)
|
||||||
|
if calories > most:
|
||||||
|
most = calories
|
||||||
|
|
||||||
|
print(most)
|
||||||
|
|
15
2022/01/part2
Executable file
15
2022/01/part2
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
elves = []
|
||||||
|
|
||||||
|
with open('input') as f:
|
||||||
|
elf = []
|
||||||
|
for line in f:
|
||||||
|
if line == "\n":
|
||||||
|
elves.append(elf)
|
||||||
|
elf = []
|
||||||
|
else:
|
||||||
|
calories = int(line)
|
||||||
|
elf.append(calories)
|
||||||
|
|
||||||
|
print(sum(sorted(map(sum, elves), reverse=True)[0:3]))
|
@@ -13,5 +13,6 @@ a programming language I'm interested in learning more about.
|
|||||||
* 2019 - Zig
|
* 2019 - Zig
|
||||||
* 2020 - JavaScript
|
* 2020 - JavaScript
|
||||||
* 2021 - Python
|
* 2021 - Python
|
||||||
|
* 2022 - Python
|
||||||
|
|
||||||
I did 2017 in LISP, but don't seem to have kept a copy of the code anywhere.
|
I did 2017 in LISP, but don't seem to have kept a copy of the code anywhere.
|
||||||
|
Reference in New Issue
Block a user