\\ * * * * * * * * * * * * * * * \\ 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); \\ 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/car init([ "..........", "A.........", "...B...C..", "..........", "..D.....E.", ".....F....", "..........", "..........", ".....G....", "..H.....I.", "..........", "...J...K..", "L.........", ".........." ]); link(pA, up(pL)); link(pA, pB); link(pA, left(pC)); link(pB, pC); link(pB, pD); link(pC, pE); link(pD, pF); link(pD, left(pE)); link(pE, pF); link(pF, pG); link(pG, pH); link(pG, pI); link(pH, left(pI)); link(pH, pJ); link(pI, pK); link(pJ, pL); link(pJ, pK); link(pK, right(pL)); } \\ A301283 Coordination sequence for node of type V1 in "car" 2-D tiling (or net). allocatemem(2^30) compute(pB, 1000); quit