-
-
Save chadsten/e329a4677bdc7de76dfa0d698acc0b3d to your computer and use it in GitHub Desktop.
AOC Day1
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
f = open("AOCDay1.txt", "r") | |
with open('AOCDay1.txt') as f: | |
elf_calories = [line.rstrip('\n') for line in f] | |
elves = [] | |
i = 0 | |
# we have to create the array element before we can add to it | |
elves.insert(i, '') | |
for elf in elf_calories: | |
if elf != "": | |
# BUG - it's appending them as strings. i bet you need to do some casting or something different than += | |
elves[i] += elf | |
else: | |
print("next") | |
i += 1 | |
# create next "elf" | |
elves.insert(i, '') | |
print(elves) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment