#!/usr/bin/python3 """Primitive cellular automata. 1-D, 3-neighborhood, 2-state. """ for rule in range(256): print('\033[H', rule) world = [0] * 128 world[64] = 1 for row in range(128): print(''.join('##' if cell else ' ' for cell in world)) world = [1 & (rule >> (world[(i - 1) % len(world)] * 4 + world[i] * 2 + world[(i + 1) % len(world)])) for i in range(len(world))] input()