JDCSTKITMUDYFXNTNYZXB7EI4GU4SWBVPVT65MAAADXGS73W5TYQC
VM4DH3Y74MPA3G3DVNXT2FALH6XVC45DLKFL64ZZD3LXNJWPFVIAC
log.Println("Part2:", SolveSecond(data))
func SolveSecond(data []Move) int { var depth, fwd, aim int for _, d := range data { switch d.dir { case "forward": fwd += d.length depth += d.length * aim case "down": aim += d.length case "up": aim -= d.length default: panic("no way!") } } return depth * fwd}
func SolveSecond(data []Move) int {
var depth, fwd, aim int
for _, d := range data {
switch d.dir {
case "forward":
fwd += d.length
depth += d.length * aim
case "down":
aim += d.length
case "up":
aim -= d.length
default:
panic("no way!")
}
return depth * fwd