day 11 python slight optimization
parent
648ce83517
commit
aeaf4f524c
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue