Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Spiral-matrix/Maple/spiral-matrix.maple
Normal file
26
Task/Spiral-matrix/Maple/spiral-matrix.maple
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
with(ArrayTools):
|
||||
|
||||
spiralArray := proc(size::integer)
|
||||
local M, sideLength, count, i, j:
|
||||
M := Matrix(size):
|
||||
count := 0:
|
||||
sideLength := size:
|
||||
for i from 1 to ceil(sideLength / 2) do
|
||||
for j from 1 to sideLength do
|
||||
M[i,i + j - 1] := count++:
|
||||
end:
|
||||
for j from 1 to sideLength - 1 do
|
||||
M[i + j, sideLength + i - 1] := count++:
|
||||
end:
|
||||
for j from 1 to sideLength - 1 do
|
||||
M[i + sideLength - 1, sideLength - j + i - 1] := count++:
|
||||
end:
|
||||
for j from 1 to sideLength - 2 do
|
||||
M[sideLength + i - j - 1, i] := count++
|
||||
end:
|
||||
sideLength -= 2:
|
||||
end:
|
||||
return M;
|
||||
end proc:
|
||||
|
||||
spiralArray(5);
|
||||
Loading…
Add table
Add a link
Reference in a new issue