\\ knight moves: \\ NW NE \\ WN EN \\ WS ES \\ SW SE [east,north,west,south] = powers(I,3) SW = -NE = 2*north+east WS = -EN = 2*east+north WN = -ES = 2*east+south NW = -SE = 2*south+east move(z) = { \\ origin if (z==0, return (z+SE)); my (x=real(z), y=imag(z)); \\ corner \\ ## ## \\ ## ## \\ ## ## \\ ## ## \\ . \\ ## ## \\ ## ## \\ ## ## \\ ## ## my (kx=(1+abs(x))\2, ky=(1+abs(y))\2); \\print ("#x="x" y="y); \\print ("#kx="kx" ky="ky); \\print ("#["if (y>0, 1, 2)","if (x<0, 1, 2)"]"); \\print ("#["if (x>0, if (x%2, 1, 2), if (x%2, 2, 1))","if (y<0, if (y%2, 1, 2), if (y%2, 2, 1))"]"); if (kx==ky, return (z + [ [ES,ES; EN,EN], [SE,SW; SE,SW]; [NE,NW; NE,NW], [WS,WS; WN,SE] ] [if (y>0, 1, 2), if (x<0, 1, 2)] [if (y<0, if (y%2, 1, 2), if (y%2, 2, 1)), if (x>0, if (x%2, 1, 2), if (x%2, 2, 1))]); ); \\ lateral corridor \\ ..#####.. \\ ..#####.. \\ ##..#..## \\ ##..#..## \\ ####.#### \\ ##..#..## \\ ##..#..## \\ ..#####.. \\ ..#####.. if (abs(y)>abs(x), if (y>0, return (z + if (y%2, EN, ES)), return (z + if (y%2, WS, WN)); ), if (x<0, return (z + if (x%2, NW, NE)), x%2==0 && x+y==2, return (z + WS), return (z + if (x%2, SE, SW)); ); ); quit; } { z = 0; for (n=0, 101^2-1, print (n " " imag(z)); z = move(z); ); } quit