diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-12-06 09:38:35 +0100 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-12-06 09:38:35 +0100 |
commit | e790654a6a8db28946ba16a3203feadb699e94ca (patch) | |
tree | 302cbc7577f37b177c931dd799667af66a3f6582 /2021/06/puzzles.py | |
parent | 3c8f652f36ff5dab1d4b9b735be4341f9dd0ee31 (diff) |
Make code a little more efficient
Diffstat (limited to '2021/06/puzzles.py')
-rw-r--r-- | 2021/06/puzzles.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/2021/06/puzzles.py b/2021/06/puzzles.py index 93dcfea..9d3f2d4 100644 --- a/2021/06/puzzles.py +++ b/2021/06/puzzles.py @@ -14,15 +14,11 @@ def main() -> None: acc = collections.Counter(map(int, f.read().split(","))) for _ in range(DAYS): - counts: Counter[int] = collections.Counter() - for a, c in acc.items(): - if a: - counts[a - 1] += c - else: - counts[6] += c - counts[8] += c - - acc = counts + n = acc[0] + for i in range(8): + acc[i] = acc[i + 1] + acc[6] += n + acc[8] = n print(sum(acc.values())) |