#!/usr/bin/env luajit require("deque") require("utils") opening = { ["["] = "]", ["{"] = "}", ["<"] = ">", ["("] = ")", } score = { ["]"] = 57, ["}"] = 1197, [">"] = 25137, [")"] = 3, } local sum = 0 for line in io.lines(arg[3]) do d = deque() for c in chars(line) do if opening[c] then d:append(opening[c]) else if c ~= d:pop() then sum = sum + score[c] break end end end end print(sum)