Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
26
Task/Sort-three-variables/Lua/sort-three-variables.lua
Normal file
26
Task/Sort-three-variables/Lua/sort-three-variables.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
function variadicSort (...)
|
||||
local t = {}
|
||||
for _, x in pairs{...} do
|
||||
table.insert(t, x)
|
||||
end
|
||||
table.sort(t)
|
||||
return unpack(t)
|
||||
end
|
||||
|
||||
local testCases = {
|
||||
{ x = 'lions, tigers, and',
|
||||
y = 'bears, oh my!',
|
||||
z = '(from the "Wizard of OZ")'
|
||||
},
|
||||
{ x = 77444,
|
||||
y = -12,
|
||||
z = 0
|
||||
}
|
||||
}
|
||||
for i, case in ipairs(testCases) do
|
||||
x, y, z = variadicSort(case.x, case.y, case.z)
|
||||
print("\nCase " .. i)
|
||||
print("\tx = " .. x)
|
||||
print("\ty = " .. y)
|
||||
print("\tz = " .. z)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue