From 469092002b7f1e1657468941bd86ccd3738baac3 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 1 Dec 2022 09:36:18 +0100 Subject: Added pre-commit --- day1/__init__.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'day1') diff --git a/day1/__init__.py b/day1/__init__.py index d7c995c..e6e4ac9 100644 --- a/day1/__init__.py +++ b/day1/__init__.py @@ -1,19 +1,16 @@ +# -*- coding: utf-8 -*- from abc import ABC from itertools import groupby from typing import Iterator, Any, List from aoc import BaseAssignment + class Assignment(BaseAssignment, ABC): def calculate_elf_calories(self, input: Iterator) -> List[int]: return [ - sum([ - int(i) - for i - in group - ]) - for in_group, group - in groupby(input, key=bool) + sum([int(i) for i in group]) + for in_group, group in groupby(input, key=bool) if in_group ] @@ -29,11 +26,4 @@ class AssignmentTwo(Assignment): example_result = 45000 def run(self, input: Iterator) -> int: - return sum( - sorted( - self.calculate_elf_calories(input), - reverse=True - )[:3] - ) - - + return sum(sorted(self.calculate_elf_calories(input), reverse=True)[:3]) -- cgit v1.2.3