Noëlle 2 år sedan
förälder
incheckning
ed3c734e37
Ingen känd nyckel hittad för denna signaturen i databasen
3 ändrade filer med 2302 tillägg och 0 borttagningar
  1. 17
    0
      day1-1.py
  2. 18
    0
      day1-2.py
  3. 2267
    0
      input1.txt

+ 17
- 0
day1-1.py Visa fil

@@ -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 Visa fil

@@ -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
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


Laddar…
Avbryt
Spara