Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,26 @@
|
|||
local function comb_sort(a)
|
||||
local gap = #a
|
||||
while true do
|
||||
gap //= 1.25
|
||||
if gap < 1 then gap = 1 end
|
||||
local i = 1
|
||||
local swaps = false
|
||||
while true do
|
||||
if a[i] > a[i + gap] then
|
||||
a[i], a[i + gap] = a[i + gap], a[i]
|
||||
swaps = true
|
||||
end
|
||||
i += 1
|
||||
if i + gap > #a then break end
|
||||
end
|
||||
if gap == 1 and !swaps then return end
|
||||
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(", ")}}")
|
||||
comb_sort(a)
|
||||
print($"After : \{{a:concat(", ")}}")
|
||||
print()
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue