diff --git a/day11/sol.py b/day11/sol.py index 52f348c..a866ee4 100644 --- a/day11/sol.py +++ b/day11/sol.py @@ -1,4 +1,4 @@ -from collections import Counter, namedtuple +from collections import namedtuple from copy import deepcopy import math @@ -25,7 +25,7 @@ def parse(input): return monkeys, items def play(monkeys, items, rounds=1, N=None): - throws = Counter() + throws = {m.index: 0 for m in monkeys} for _ in range(rounds): for m in monkeys: for x in items[m.index]: @@ -46,7 +46,7 @@ def show(items): print(k, items[k]) def monkeybusiness(throws): - a, b = [x[1] for x in throws.most_common(2)] + a, b = sorted(throws.values())[-2:] return a*b def lcm(ints):