Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,19 @@
|
|||
local function stooge_sort(a, i, j)
|
||||
if a[j] < a[i] then
|
||||
a[i], a[j] = a[j], a[i]
|
||||
end
|
||||
if j - i > 1 then
|
||||
local t = (j - i + 1) // 3
|
||||
stooge_sort(a, i, j - t)
|
||||
stooge_sort(a, i + t, j)
|
||||
stooge_sort(a, i, j - t)
|
||||
end
|
||||
end
|
||||
|
||||
local array = { {4, 65, 2, -31, 0, 99, 2, 83, 782, 1}, {7, 5, 2, 6, 1, 4, 2, 6, 3} }
|
||||
for array as a do
|
||||
print($"Before: \{{a:concat(", ")}}")
|
||||
stooge_sort(a, 1, #a)
|
||||
print($"After : \{{a:concat(", ")}}")
|
||||
print()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue