From fcee79a5893eb4a8cf4b6753d5d4b31ecc337fa9 Mon Sep 17 00:00:00 2001 From: Sourcery AI <> Date: Mon, 12 Dec 2022 13:42:01 +0000 Subject: [PATCH] 'Refactored by Sourcery' --- Advent of Code/2022/Day 1/day1.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Advent of Code/2022/Day 1/day1.py b/Advent of Code/2022/Day 1/day1.py index d635dfe..89d57f8 100644 --- a/Advent of Code/2022/Day 1/day1.py +++ b/Advent of Code/2022/Day 1/day1.py @@ -13,14 +13,16 @@ def parse(file): def part_1(lst): - print(f'The total number of calories that the elf is carrying is: {max([sum(ele) for ele in lst])}') + print( + f'The total number of calories that the elf is carrying is: {max(sum(ele) for ele in lst)}' + ) def part_2(lst): res, num_max = 0, 3 sums_heap = [-1 * sum(ele) for ele in lst] heapq.heapify(sums_heap) - for i in range(num_max): + for _ in range(num_max): res += -1 * heapq.heappop(sums_heap) print(f'The total number of calories that the elves are carrying is: {res}')