dz = powers(I, 3) dz = concat(dz, dz*(1+I)) neighbours(z) = { apply (d -> d+z, dz); } nb live neighbours(live, z) = { my (nb = #select(zz -> setsearch(live, zz), neighbours(z))); nb } iterate(live) = { if (live==[], return ([])); my (dead = setminus(Set(concat(apply(neighbours, live))), live)); set union( select(z -> nb live neighbours(live, z)==5, live), select(z -> my (nb=nb live neighbours(live, z)); nb >= 3 && nb <= 5, dead) ); } a(n) = { my (w = [1..n], ww=iterate(w)); while (w!=ww, w=iterate(w); ww=iterate(ww); ww=iterate(ww); ); for (p=1, oo, ww = iterate(ww); if (w==ww, \\ 0 means 1!?! return (if (p>1, p, 0)); ); ); } for (n=1, 100, print (n " " a(n))) quit