Skip to content

Instantly share code, notes, and snippets.

@mdempsky
Created December 12, 2020 07:15
Show Gist options
  • Save mdempsky/d5100a711db8d370ff7ab645bf47a8d0 to your computer and use it in GitHub Desktop.
Save mdempsky/d5100a711db8d370ff7ab645bf47a8d0 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sort"
advent "github.com/mdempsky/advent2020"
)
func main() {
joltages := advent.InputInts()
sort.Ints(joltages)
var distinct [3]int
joltage := 0
distinct[joltage] = 1
for len(joltages) > 0 {
joltage++
x := 0
if joltage == joltages[0] {
joltages = joltages[1:]
x = distinct[0] + distinct[1] + distinct[2]
}
distinct[joltage%3] = x
}
fmt.Println(distinct[joltage%3])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment