One-dimensional cellular automata: Difference between revisions

→‎Python: Sum neighbours == 2: Simpler initialization.
(→‎Python: Sum neighbours == 2: Simpler initialization.)
Line 2,402:
===Python: Sum neighbours == 2===
This example makes use of the observation that a cell is alive in the next generation if the sum with its current neighbours of alive cells is two.
<lang python>>>> gen = [int(ch) == '#' for ch in '_###_##_#_#_#_#__#__'.replace('_', '0').replace('#', '1')]
>>> for n in range(10):
print(''.join('#' if cell else '_' for cell in gen))
Anonymous user