From e806b43689f78c1d7f858d84c2c40b2ddcd67540 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 8 Dec 2021 15:31:49 +0100 Subject: Compress 5 lines into 1 --- 2020/16/puzzle-1.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/2020/16/puzzle-1.py b/2020/16/puzzle-1.py index 9f35856..c7cba37 100755 --- a/2020/16/puzzle-1.py +++ b/2020/16/puzzle-1.py @@ -14,14 +14,12 @@ def main() -> None: valid.extend(range(bounds[0], bounds[1] + 1)) i += 1 - # Skip to nearby tickets - i += 5 - acc = 0 - - for j in range(i, len(data)): - acc += sum(field for field in tuple(map(int, data[j].split(","))) if field not in valid) - - print(acc) + print( + sum( + sum(field for field in tuple(map(int, data[j].split(","))) if field not in valid) + for j in range(i + 5, len(data)) + ) + ) if __name__ == "__main__": -- cgit v1.2.3