Day 1 2022
This commit is contained in:
parent
640e7a29b1
commit
fa98ccf4c3
2 changed files with 33 additions and 0 deletions
14
Python/2022/01/input
Normal file
14
Python/2022/01/input
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
1000
|
||||||
|
2000
|
||||||
|
3000
|
||||||
|
|
||||||
|
4000
|
||||||
|
|
||||||
|
5000
|
||||||
|
6000
|
||||||
|
|
||||||
|
7000
|
||||||
|
8000
|
||||||
|
9000
|
||||||
|
|
||||||
|
10000
|
||||||
19
Python/2022/01/main.py
Normal file
19
Python/2022/01/main.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
input = open("input", 'r')
|
||||||
|
|
||||||
|
data = [0 for _ in range(400)]
|
||||||
|
|
||||||
|
elf = 0
|
||||||
|
|
||||||
|
for line in input:
|
||||||
|
if line == "\n":
|
||||||
|
elf += 1
|
||||||
|
else:
|
||||||
|
if data[elf]:
|
||||||
|
data[elf] += int(line)
|
||||||
|
else:
|
||||||
|
data[elf] = int(line)
|
||||||
|
|
||||||
|
sortedData = sorted(data, reverse=True)
|
||||||
|
|
||||||
|
print(sortedData[0])
|
||||||
|
print(sortedData[0] + sortedData[1] + sortedData[2])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue