From fa931d5cb2e70b4878ba60aa443899a80038afe1 Mon Sep 17 00:00:00 2001 From: Ryan Reed Date: Tue, 7 Dec 2021 20:27:37 -0500 Subject: [PATCH] Cleaning up format --- puzzles/day07.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/puzzles/day07.py b/puzzles/day07.py index 127bcd5..79aa27c 100644 --- a/puzzles/day07.py +++ b/puzzles/day07.py @@ -18,17 +18,17 @@ class AlignCrabSubs: self.positions = positions def calc_fuel(self, pricey: bool = False) -> int: - if pricey: - fuel = None - for position in range(len(set(self.positions)) + 1): - price = self.calc_fuel_pricey(position) - if fuel is None or fuel > price: - fuel = price - - return fuel - else: + if not pricey: return self.calc_fuel_simple(median(self.positions)) + fuel = None + for position in range(len(set(self.positions)) + 1): + price = self.calc_fuel_pricey(position) + if fuel is None or fuel > price: + fuel = price + + return fuel + def calc_fuel_simple(self, target: int) -> int: return int(sum(abs(num - target) for num in self.positions))