-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
516e97c
commit a726beb
Showing
16 changed files
with
6,310 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.') | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
1000 | ||
2000 | ||
3000 | ||
|
||
4000 | ||
|
||
5000 | ||
6000 | ||
|
||
7000 | ||
8000 | ||
9000 | ||
|
||
10000 |
Oops, something went wrong.