aboutsummaryrefslogtreecommitdiff
path: root/challenge-271/deadmarshal/lua/ch-1.lua
blob: 159d14847368d8b766da5bc3c5dd402a4433d00f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env lua

local function sum(t)
  assert(type(t) == 'table','t must be a table!')
  local s = 0
  for i=1,#t do s = s + t[i] end
  return s
end

local function maximum_ones(t)
  assert(type(t) == 'table','t must be a table!')
  local max = 0
  for i=1,#t do
    local s = sum(t[i])
    if s > max then max = s end
  end
  return max
end

print(maximum_ones{{0,1},{1,0}})
print(maximum_ones{{0,0,0},{1,0,1}})
print(maximum_ones{{0,0},{1,1},{0,0}})