Skip to content

Commit

Permalink
Solving day 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ardy committed Dec 1, 2022
1 parent db53d19 commit 3cbc620
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
17 changes: 14 additions & 3 deletions code/day_1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
from helper import *

# data = readNumbers("day_1/example.txt")
data = readNumbers("./days/day_1/example.txt")
data = readStrings("./days/day_1/problem.txt")
# data = readStrings("./days/day_1/example.txt")

print(data)
result = []
current_sum = 0

for i in range(0, len(data)):
if (data[i] == ''):
result.append(current_sum)
current_sum = 0
else:
current_sum += int(data[i])

print('day1_1:', sorted(result)[-1])
print('day1_2:', sum([sorted(result)[-1], sorted(result)[-2], sorted(result)[-3]]))
14 changes: 14 additions & 0 deletions days/day_1/example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
1000
2000
3000

4000

5000
6000

7000
8000
9000

10000

0 comments on commit 3cbc620

Please sign in to comment.