Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Spiral-matrix/Zkl/spiral-matrix-1.zkl
Normal file
9
Task/Spiral-matrix/Zkl/spiral-matrix-1.zkl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
fcn spiralMatrix(n){
|
||||
sm:=(0).pump(n,List,(0).pump(n,List,False).copy); //L(L(False,False..), L(F,F,..) ...)
|
||||
drc:=Walker.cycle(T(0,1,0), T(1,0,1), T(0,-1,0), T(-1,0,1)); // deltas
|
||||
len:=n; r:=0; c:=-1; z:=-1; while(len>0){ //or do(2*n-1){
|
||||
dr,dc,dl:=drc.next();
|
||||
do(len-=dl){ sm[r+=dr][c+=dc]=(z+=1); }
|
||||
}
|
||||
sm
|
||||
}
|
||||
4
Task/Spiral-matrix/Zkl/spiral-matrix-2.zkl
Normal file
4
Task/Spiral-matrix/Zkl/spiral-matrix-2.zkl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
foreach n in (T(5,-1,0,1,2)){
|
||||
spiralMatrix(n).pump(Console.println,fcn(r){ r.apply("%4d".fmt).concat() });
|
||||
println("---");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue