diff options
author | Jack Sangdahl <[email protected]> | 2024-06-15 22:20:32 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2024-06-15 22:20:32 -0600 |
commit | 8e313e2614c7a0fe5af924febdbacc650e33835e (patch) | |
tree | 63426b6942ceebe17708140c972a7d7451bd2f74 /6_2021.py | |
download | aoc-8e313e2614c7a0fe5af924febdbacc650e33835e.tar.gz aoc-8e313e2614c7a0fe5af924febdbacc650e33835e.zip |
intial
Diffstat (limited to '6_2021.py')
-rw-r--r-- | 6_2021.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/6_2021.py b/6_2021.py new file mode 100644 index 0000000..b8e0304 --- /dev/null +++ b/6_2021.py @@ -0,0 +1,23 @@ +import sys +from collections import defaultdict, Counter + +data = sys.argv[1] if len(sys.argv) > 1 else "../day6data.txt" +X = Counter([int(x) for x in open(data).read().strip().split(",")]) + + +def solve(S, n): + X = S + for day in range(n): + Y = defaultdict(int) + for x, cnt in X.items(): + if x == 0: + Y[6] += cnt + Y[8] += cnt + else: + Y[x - 1] += cnt + X = Y + return sum(X.values()) + + +print(solve(X, 80)) +print(solve(X, 256)) |