Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
488 B · 26 lines
Lua
at main
123456789101112131415161718192021222324252627local input = io.open("input.txt", "r")
local total = 0
local function min(a, b, c) if a < b then return a < c and a or c end return b < c and b or cend
for line in input:lines("l") do local l, w, h = line:match("(%d+)x(%d+)x(%d+)") l = tonumber(l) w = tonumber(w) h = tonumber(h)
total = total + 2 * (l * w + w * h + h * l)
total = total + min(l * w, w * h, h * l)end
print("Total square feet required: " .. total)
input:close()