\\ * * * * * * * * * * * * * * * \\ coordination sequence library \\ * * * * * * * * * * * * * * * width = -1 height = -1 coord = matrix(0,0) labels = matrix(0,0) init(screen) = { height = #screen; width = #screen[1]; coord = matrix(width, height, x, y, []); labels = matrix(width, height, x, y, ""); for (s=1, #screen, my (y=#screen - s); my (row = Vec(screen[s])); for (x=0, #row-1, my (d = row[x+1]); if ( (d >= "A" && d <= "Z") || (d >= "a" && d <= "Z") || (d >= "0" && d <= "9"), eval(Str("p" d "=" x+I*y)); labels[1+x, 1+y] = d; ); ); ); } up (z) = z + I*height down (z) = z - I*height right(z) = z + width left (z) = z - width \\ unidirectional link link1(z, zz) = { my (x=real(z) % width, y=imag(z) % height); coord[1+x, 1+y] = concat(coord[1+x, 1+y], zz-z); } \\ bidirectional link link(a, b) = link1(a, b); link1(b, a); \\ bidirectional links from same origin links(a, bb) = for (i=1, #bb, link(a, bb[i])); \\ neighbours neighbours(z) = { my (x=real(z) % width, y=imag(z) % height); my (n = apply (c -> c + z, coord[1+x, 1+y])); \\ print ("#" z " -> " n); return (n); } compute(z, mx) = { my (explored = Set()); my (current = Set(z)); for (n=0, mx, \\ print ("#" current); print (n " " #current); if (n==mx, break); explored = set union(explored, current); my (others = concat(apply(neighbours, current))); current = set minus(Set(others), explored); ); } { \\ http://rcsr.net/layers/bil init([ "....................", ".......A.....B......", "..........C.........", "....D...........E...", "F.........G.........", "......H.......I.....", "J...................", "....K...........L...", "....................", "....M...........N...", "O...................", "......P.......Q.....", "S.........T.........", "....U...........V...", "..........W.........", ".......X.....Y......" ]); links(pA, [ up(pX), pC, pD ]); links(pB, [ up(pY), pC, pE ]); links(pC, [ pG ]); links(pD, [ pF, pH ]); links(pE, [ pI, right(pF) ]); links(pF, [ pJ ]); links(pG, [ pH, pI ]); links(pH, [ pK ]); links(pI, [ pL ]); links(pJ, [ pK, left(pL) ]); links(pK, [ pM ]); links(pL, [ pN ]); links(pM, [ pO, pP ]); links(pN, [ right(pO), pQ ]); links(pO, [ pS ]); links(pP, [ pU, pT ]); links(pQ, [ pT, pV ]); links(pS, [ pU, left(pV) ]); links(pT, [ pW ]); links(pU, [ pX ]); links(pV, [ pY ]); links(pW, [ pX, pY ]); } \\ A298792 Coordination sequence for the bil tiling (or net) with respect to a trivalent node of the first type. allocatemem(2^30) compute(pA, 1000); quit