Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SpawnTerror authored Dec 19, 2022
1 parent 516e97c commit a726beb
Show file tree
Hide file tree
Showing 16 changed files with 6,310 additions and 0 deletions.
2,236 changes: 2,236 additions & 0 deletions day1/input.txt

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions day1/part1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SpawnTerror 2022
# Python 3.11.1
# AOC Day 1

# Parse input data into a list, strip line breaks
with open('day1/input.txt', 'r') as f:
entries = []
for line in f:
entries.append(line.rstrip())

# Count elves by checking for line break
elves = entries.count('') + 1
print(f'Elves = ', elves)

# Create a list with total calories for each elf
totals = []
count = 0

# Iterate through all entries, addidng them up until a line break
for i in entries:
if i != '':
count = count + int(i)
else:
totals.append(count)
count = 0

# Show the biggest integer in the list of totals
print(f'Elf with most calories is carrying ', max(totals), 'calories.')





29 changes: 29 additions & 0 deletions day1/part2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SpawnTerror 2022
# Python 3.11.1
# AOC Day 1

# Parse input data into a list, strip line breaks
with open('day1/input.txt', 'r') as f:
entries = []
for line in f:
entries.append(line.rstrip())

# Count elves by checking for line break
elves = entries.count('') + 1
print(f'Elves = ', elves)

# Create a list with total calories for each elf
totals = []
count = 0

# Iterate through all entries, addidng them up until a line break
for i in entries:
if i != '':
count = count + int(i)
else:
totals.append(count)
count = 0

# Sort the totals and calculate sum of the last 3 items
sort = sorted(totals)
print(f'Top 3 Elves are carrying ', sum(sort[-3:]))
14 changes: 14 additions & 0 deletions day1/test.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
Loading

0 comments on commit a726beb

Please sign in to comment.