Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Spiral-matrix/Phix/spiral-matrix.phix
Normal file
19
Task/Spiral-matrix/Phix/spiral-matrix.phix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
integer n = 5
|
||||
string fmt = sprintf("%%%dd",length(sprintf("%d",n*n)))
|
||||
integer x = 1, y = 0, c = 0, dx = 0, dy = 1, len = n
|
||||
sequence m = repeat(repeat("??",n),n)
|
||||
for i=1 to 2*n do -- 2n runs..
|
||||
for j=1 to len do -- of a length...
|
||||
x += dx
|
||||
y += dy
|
||||
m[x][y] = sprintf(fmt,c)
|
||||
c += 1
|
||||
end for
|
||||
len -= and_bits(i,1) -- ..-1 every other
|
||||
{dx,dy} = {dy,-dx} -- in new direction
|
||||
end for
|
||||
|
||||
for i=1 to n do
|
||||
m[i] = join(m[i])
|
||||
end for
|
||||
puts(1,join(m,"\n"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue