aboutsummaryrefslogtreecommitdiff
path: root/2021/07/puzzles.py
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-07 06:37:09 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-07 06:37:09 +0100
commit3432015669c91ed073f2b3121948264840282df2 (patch)
tree886b40885c3ba17ac307170896631f718fc38870 /2021/07/puzzles.py
parent8ebd49714cf7e8dec2f119d4ba6f44f485d0e8c7 (diff)
Minor performance improvement
Diffstat (limited to '2021/07/puzzles.py')
-rw-r--r--2021/07/puzzles.py7
1 files changed, 6 insertions, 1 deletions
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__":