From 3432015669c91ed073f2b3121948264840282df2 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 7 Dec 2021 06:37:09 +0100 Subject: Minor performance improvement --- 2021/07/puzzles.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/2021/07/puzzles.py b/2021/07/puzzles.py index b0ccb32..bfd9bb3 100644 --- a/2021/07/puzzles.py +++ b/2021/07/puzzles.py @@ -15,7 +15,12 @@ def main() -> None: with open("input", "r", encoding="utf-8") as f: data = list(map(int, f.read().split(","))) - print(min(sum(gauss_sum(abs(i - data[j])) for j in range(len(data))) for i in range(max(data)))) + print( + min( + sum(gauss_sum(abs(i - data[j])) for j in range(len(data))) + for i in range(min(data), max(data) + 1) + ) + ) if __name__ == "__main__": -- cgit v1.2.3