diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-12-01 08:55:41 +0100 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-12-01 08:55:41 +0100 |
commit | 32fe21038a75a3f6da911c92247e422885cb521b (patch) | |
tree | 9520485ba9db31d41b8ca0e1a789d0f510b61076 /2021/01 | |
parent | aafb97eb7f186c56992a0be6a50c4df4058bd4ed (diff) |
Make use of the magic zip function
Diffstat (limited to '2021/01')
-rw-r--r-- | 2021/01/puzzles.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/2021/01/puzzles.py b/2021/01/puzzles.py index 0a894ca..d9a704b 100644 --- a/2021/01/puzzles.py +++ b/2021/01/puzzles.py @@ -4,10 +4,7 @@ def main() -> None: with open("input", "r") as f: nums = [int(n) for n in f.readlines()] - # START PART 2 - nums = [nums[i] + nums[i - 1] + nums[i - 2] for i in range(2, len(nums))] - # END PART 2 - print(sum(nums[i] > nums[i - 1] for i in range(1, len(nums)))) + print(sum(n < m for n, m in zip(nums, nums[DELTA:]))) if __name__ == "__main__": main() |