aboutsummaryrefslogtreecommitdiff
path: root/challenge-228/deadmarshal/lua/ch-2.lua
blob: 8f3245f208fcc6bd0c1dc8cd63b4cec5ac67a658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env lua

local function empty_array(t)
  local count = 0
  while #t ~= 0 do
    if t[1] == math.min(table.unpack(t)) then table.remove(t,1)
    else table.insert(t,table.remove(t,1)) end
    count = count + 1
  end
  return count
end

print(empty_array({3,4,2}))
print(empty_array({1,2,3}))