\\ Kolakoski's sequence K = vector(10 000) K[1] = 1 K[2] = 2 u = 0 for (r=1, oo, for (i=1, K[r], K[u++] = 2-(r%2); if (u==#K, break (2)))) { prev = 0; for (n=1, #K, forstep (s=min(n, prev+2), 1, -1, suffix = K[n-s+1..n]; if (Vecrev(suffix)==suffix, print (n " " prev=s); break; ); ); ); } quit