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

local function number_placement(t,count)
  if #t < 3 then return false end
  local c = 0
  for i=1,#t-1 do
    if t[i-1] == 0 and t[i+1] == 0 then c = c + 1 end
  end
  return c >= count
end

print(number_placement({1,0,0,0,1},1))
print(number_placement({1,0,0,0,1},2))
print(number_placement({1,0,0,0,0,0,0,0,1},3))