@@ -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() |
@@ -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() |