Browse Source

Day 1

master
Noëlle 1 year ago
parent
commit
ed3c734e37
No known key found for this signature in database
3 changed files with 2302 additions and 0 deletions
  1. 17
    0
      day1-1.py
  2. 18
    0
      day1-2.py
  3. 2267
    0
      input1.txt

+ 17
- 0
day1-1.py View File

@@ -0,0 +1,17 @@
# https://adventofcode.com/2022/day/1

def main():
with open("input1.txt", "r") as file:
indata = file.read()
elves = indata.split("\n\n")

elf_cals = []
for i, elf in enumerate(elves):
cal_lines = [int(x) for x in elf.split("\n")]
elf_cals.append((i,sum(cal_lines)))
elf_cals_sorted = sorted(elf_cals, reverse=True, key=lambda x: x[1])
print(elf_cals_sorted[0])

if __name__ == "__main__":
main()

+ 18
- 0
day1-2.py View File

@@ -0,0 +1,18 @@
# https://adventofcode.com/2022/day/1

def main():
with open("input1.txt", "r") as file:
indata = file.read()
elves = indata.split("\n\n")

elf_cals = []
for i, elf in enumerate(elves):
cal_lines = [int(x) for x in elf.split("\n")]
elf_cals.append((i,sum(cal_lines)))
elf_cals_sorted = sorted(elf_cals, reverse=True, key=lambda x: x[1])
most_snacks = elf_cals_sorted[:3]
print(sum([x[1] for x in most_snacks]))

if __name__ == "__main__":
main()

+ 2267
- 0
input1.txt
File diff suppressed because it is too large
View File


Loading…
Cancel
Save