-- Day 6 Lua -- local input_file = "Day6/full" local input = {} local rows = 0 local cols = 0 local total = 0 -- -- for line in io.lines(input_file) do local col = {} rows = rows + 1 for I in line:gmatch("[%d*++-%%]+") do table.insert(col, I) end table.insert(input, col) end for _ in ipairs(input[1]) do cols = cols + 1 end for loop_col = 1, cols do local calculation = input[rows][loop_col] local output = calculation .. " " local result = input[1][loop_col] output = output .. " " .. result for loop_row = 2, rows - 1 do local num = input[loop_row][loop_col] output = output .. " " .. num if calculation == "+" then result = result + num elseif calculation == "*" then result = result * num else print("Weird calculation") end end output = output .. " = " .. result print(output) total = total + result end print("End Total " .. total)