day 8 part 1

This commit is contained in:
Felix Van der Jeugt 2021-12-08 08:37:36 +01:00
parent 602bc416d8
commit 0416db0542
No known key found for this signature in database
GPG key ID: 58B209295023754D
2 changed files with 36 additions and 0 deletions

View file

@ -23,3 +23,18 @@ function foreach(t, f)
t[k] = f(v)
end
end
function printtable(t)
for k, v in pairs(t) do
io.write(k..":"..v.." ")
end
io.write("\n")
end
function count(t, pred)
local count = 0
for k, v in pairs(t) do
if pred(v) then count = count + 1 end
end
return count
end