VGCY37EZI6VDEH6ARTGQA6FQYESWTZZGIZR32OZETOVWPVLOZORQC
2LFPR4DA4MFO3K7CPDL7U53USUAQK4CNYL4N6447XDJYE4RJU5SAC
log.Println("Part2:", solveSecond(joltOut))
}func solveSecond(jolts []int) int { sum := 1 count := 0 for i, jt := range jolts { if i == 0 { continue } if jt-jolts[i-1] == 1 { count++ } else { switch count { case 4: sum *= 7 // ways to arrange 4 item case 3: sum *= 4 case 2: sum *= 2 } count = 0 } } return sum
}
func solveSecond(jolts []int) int {
sum := 1
count := 0
for i, jt := range jolts {
if i == 0 {
continue
if jt-jolts[i-1] == 1 {
count++
} else {
switch count {
case 4:
sum *= 7 // ways to arrange 4 item
case 3:
sum *= 4
case 2:
sum *= 2
count = 0
return sum