adventofcode-2021/day08/part1.lua

22 lines
441 B
Lua
Raw Normal View History

2021-12-08 08:37:36 +01:00
#!/usr/bin/env luajit
require("utils")
function isunique(v)
return #v == 2 or #v == 3 or #v == 4 or #v == 7
end
local entries = {}
local uniques = 0
for line in io.lines(arg[3]) do
local words = split(line, " ")
local patterns = { unpack(words, 1, 10) }
local values = { unpack(words, 12, #words) }
table.insert(entries, {
patterns = patterns,
values = values,
})
uniques = uniques + count(values, isunique)
end
print(uniques)