Skip to content

Instantly share code, notes, and snippets.

@chadsten
Forked from BazingaThat/aocday1.py
Last active September 26, 2023 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadsten/e329a4677bdc7de76dfa0d698acc0b3d to your computer and use it in GitHub Desktop.
Save chadsten/e329a4677bdc7de76dfa0d698acc0b3d to your computer and use it in GitHub Desktop.
AOC Day1
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