This commit is contained in:
parent
9598e8f526
commit
940d738c4f
3 changed files with 2289 additions and 0 deletions
20
2022/1/1.py
Normal file
20
2022/1/1.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
# 2022 - Advent Of Code 1
|
||||
|
||||
# file = 'input_example.txt'
|
||||
file = 'input.txt'
|
||||
|
||||
calories = []
|
||||
with open(file, encoding="utf-8") as f:
|
||||
accum = 0
|
||||
for line in f.readlines():
|
||||
if line == '\n':
|
||||
# next elf
|
||||
calories.append(accum)
|
||||
accum = 0
|
||||
else:
|
||||
accum += int(line)
|
||||
calories.append(accum)
|
||||
|
||||
print(calories)
|
||||
print(max(calories))
|
2255
2022/1/input.txt
Normal file
2255
2022/1/input.txt
Normal file
File diff suppressed because it is too large
Load diff
14
2022/1/input_example.txt
Normal file
14
2022/1/input_example.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
1000
|
||||
2000
|
||||
3000
|
||||
|
||||
4000
|
||||
|
||||
5000
|
||||
6000
|
||||
|
||||
7000
|
||||
8000
|
||||
9000
|
||||
|
||||
10000
|
Loading…
Reference in a new issue