Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,24 @@
local function is_sorted(a)
for i = 1, #a - 1 do
if a[i] > a[i + 1] then return false end
end
return true
end
local a = {170, 45, 75, -90, -802, 24, 2, 66}
-- Recursive permutation generator.
local function recurse(last)
if last <= 1 then return is_sorted(a) end
for i = 1, last do
a[i], a[last] = a[last], a[i]
if recurse(last - 1) then return true end
a[i], a[last] = a[last], a[i]
end
return false
end
print($"Unsorted: \{{a:concat(", ")}}")
local c = #a
if c > 1 and !recurse(c) then error("Sorted permutation not found!") end
print($"Sorted : \{{a:concat(", ")}}")