file = io.open("input") io.input(file) score = 0 function find_duplicates(first, second) for i = 1, #first do local char = string.sub(first, i, i) if string.find(second, char) then if char == string.upper(char) then return string.byte(char) - string.byte("A") + 27 elseif char == string.lower(char) then return string.byte(char) - string.byte("a") + 1 end end end end for line in file:lines() do local first = string.sub(line, 1, #line/2) local second = string.sub(line, #line/2 + 1, #line) score = score + find_duplicates(first, second) end print(score)