Code for the Advent of Code event
aoc
advent-of-code
1local input = io.open("input.txt", "r")
2
3local total = 0
4
5local function min(a, b, c)
6 if a < b then
7 return a < c and a or c
8 end
9
10 return b < c and b or c
11end
12
13for line in input:lines("l") do
14 local l, w, h = line:match("(%d+)x(%d+)x(%d+)")
15 l = tonumber(l)
16 w = tonumber(w)
17 h = tonumber(h)
18
19 total = total + 2 * (l * w + w * h + h * l)
20
21 total = total + min(l * w, w * h, h * l)
22end
23
24print("Total square feet required: " .. total)
25
26input:close()