aoc/aoc2015/day02.go

22 lines
387 B
Go
Raw Normal View History

2024-07-24 14:29:59 +00:00
package aoc2015
2024-07-24 18:03:39 +00:00
import (
"aoc/internal/utility"
"fmt"
)
2024-07-24 14:29:59 +00:00
func day02() {
2024-07-24 18:03:39 +00:00
in := utility.GetLines("input/2015/02")
var h, w, l, p1, p2 int
for _, line := range in {
_, err := fmt.Sscanf(line, "%dx%dx%d", &l, &w, &h)
utility.E(err)
p1 += 2*l*w + 2*w*h + 2*h*l + min(l*w, min(w*h, h*l))
p2 += l*w*h + min(l*2+w*2, min(w*2+h*2, h*2+l*2))
}
fmt.Println(p1)
fmt.Println(p2)
2024-07-24 14:29:59 +00:00
}