collections.Counter should implement fromkeys
27 Jun
2018
27 Jun
'18
8:36 p.m.
Consider the following update function for conway's game of life:
from collections import Counter
def update(live: Set[Tuple[Integer, Integer]]):
counts = Counter.fromkeys(live, 0) + Counter(itertools.chain(neighbors(*
cell) for cell in live))
flip = {cell for cell, count in counts.items()
if (cell in live and not 1
2128
Age (days ago)
2128
Last active (days ago)
0 comments
1 participants
participants (1)
-
Abe Dillon