Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -3,35 +3,35 @@ set n to 5 -- Size of zig-zag matrix (n^2 cells).
-- Create an empty matrix.
set m to {}
repeat with i from 1 to n
set R to {}
repeat with j from 1 to n
set end of R to 0
end repeat
set end of m to R
set R to {}
repeat with j from 1 to n
set end of R to 0
end repeat
set end of m to R
end repeat
-- Populate the matrix in a zig-zag manner.
set {x, y, v, d} to {1, 1, 0, 1}
repeat while v < (n ^ 2)
if 1 x and x n and 1 y and y n then
set {m's item y's item x, x, y, v} to {v, x + d, y - d, v + 1}
else if x > n then
set {x, y, d} to {n, y + 2, -d}
else if y > n then
set {x, y, d} to {x + 2, n, -d}
else if x < 1 then
set {x, y, d} to {1, y, -d}
else if y < 1 then
set {x, y, d} to {x, 1, -d}
end if
if 1 x and x n and 1 y and y n then
set {m's item y's item x, x, y, v} to {v, x + d, y - d, v + 1}
else if x > n then
set {x, y, d} to {n, y + 2, -d}
else if y > n then
set {x, y, d} to {x + 2, n, -d}
else if x < 1 then
set {x, y, d} to {1, y, -d}
else if y < 1 then
set {x, y, d} to {x, 1, -d}
end if
end repeat
--> R = {{0, 1, 5, 6, 14}, {2, 4, 7, 13, 15}, {3, 8, 12, 16, 21}, {9, 11, 17, 20, 22}, {10, 18, 19, 23, 24}}
-- Reformat the matrix into a table for viewing.
repeat with i in m
repeat with j in i
set j's contents to (characters -(length of (n ^ 2 as string)) thru -1 of (" " & j)) as string
end repeat
set end of i to return
repeat with j in i
set j's contents to (characters -(length of (n ^ 2 as string)) thru -1 of (" " & j)) as string
end repeat
set end of i to return
end repeat
return return & m as string

View file

@ -2,33 +2,33 @@ set n to 5
set m to {}
repeat with i from 1 to n
set end of m to {} -- Built a foundation for the matrix out of n empty lists.
set end of m to {} -- Built a foundation for the matrix out of n empty lists.
end repeat
set {v, d, i} to {0, -1, 1}
repeat while v < n ^ 2
if length of m's item i < n then
set {end of m's item i, i, v} to {f(v, n), i + d, v + 1}
if i < 1 then
set {i, d} to {1, -d}
else if i > n then
set {i, d} to {n, -d}
else if i > 1 and (count of m's item (i - 1)) = 1 then
set d to -d
end if
else
set {i, d} to {i + 1, 1}
end if
if length of m's item i < n then
set {end of m's item i, i, v} to {f(v, n), i + d, v + 1}
if i < 1 then
set {i, d} to {1, -d}
else if i > n then
set {i, d} to {n, -d}
else if i > 1 and (count of m's item (i - 1)) = 1 then
set d to -d
end if
else
set {i, d} to {i + 1, 1}
end if
end repeat
-- Handler/function to format the cells on the fly.
on f(v, n)
return (characters -(length of (n ^ 2 as string)) thru -1 of (" " & v)) as string
return (characters -(length of (n ^ 2 as string)) thru -1 of (" " & v)) as string
end f
-- Reformat the matrix into a table for viewing.
set text item delimiters to ""
repeat with i in m
set i's contents to (i as string) & return
set i's contents to (i as string) & return
end repeat
return return & m as string