From 69bfaf2d84d210ba563a8f789345667aa34867c0 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Mon, 6 Dec 2021 10:08:26 -0500 Subject: [PATCH] day6: Clean up b.py --- 6/b.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/6/b.py b/6/b.py index e2979bd..3f0c4b9 100755 --- a/6/b.py +++ b/6/b.py @@ -2,23 +2,11 @@ import sys # rather than keep a raw list, count number of each type! -counts = [0, 0, 0, 0, 0, 0, 0, 0, 0] - -def repro(fish): - new = [] - for f in fish: - if f == 0: - new += [6, 8] - else: - new.append(f - 1) - - return new +counts = [0] * 9 for l in sys.stdin: - # just keep the last one (only one) - fish = [int(x) for x in l.split(',')] - for f in fish: - counts[f] += 1 + for f in l.split(","): + counts[int(f)] += 1 for i in range(256): ready = counts.pop(0) -- libgit2 1.8.1