Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
4
Task/Zig-zag-matrix/Mathematica/zig-zag-matrix-1.math
Normal file
4
Task/Zig-zag-matrix/Mathematica/zig-zag-matrix-1.math
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ZigZag[size_Integer/;size>0]:=Module[{empty=ConstantArray[0,{size,size}]},
|
||||
empty=ReplacePart[empty,{i_,j_}:>1/2 (i+j)^2-(i+j)/2-i (1-Mod[i+j,2])-j Mod[i+j,2]];
|
||||
ReplacePart[empty,{i_,j_}/;i+j>size+1:> size^2-tmp[[size-i+1,size-j+1]]-1]
|
||||
]
|
||||
15
Task/Zig-zag-matrix/Mathematica/zig-zag-matrix-2.math
Normal file
15
Task/Zig-zag-matrix/Mathematica/zig-zag-matrix-2.math
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
ZigZag2[size_] := Module[{data, i, j, elem},
|
||||
data = ConstantArray[0, {size, size}];
|
||||
i = j = 1;
|
||||
For[elem = 0, elem < size^2, elem++,
|
||||
data[[i, j]] = elem;
|
||||
If[Mod[i + j, 2] == 0,
|
||||
If[j < size, j++, i += 2];
|
||||
If[i > 1, i--]
|
||||
,
|
||||
If[i < size, i++, j += 2];
|
||||
If[j > 1, j--];
|
||||
];
|
||||
];
|
||||
data
|
||||
]
|
||||
2
Task/Zig-zag-matrix/Mathematica/zig-zag-matrix-3.math
Normal file
2
Task/Zig-zag-matrix/Mathematica/zig-zag-matrix-3.math
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ZigZag[5] // MatrixForm
|
||||
ZigZag2[6] // MatrixForm
|
||||
Loading…
Add table
Add a link
Reference in a new issue