Anonymous user
One-dimensional cellular automata: Difference between revisions
→Python: Sum neighbours == 2: Simpler initialization.
m (→Python: Sum neighbours == 2: Whoops!) |
(→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 = [
>>> for n in range(10):
print(''.join('#' if cell else '_' for cell in gen))
|