Created
December 12, 2020 07:15
-
-
Save mdempsky/d5100a711db8d370ff7ab645bf47a8d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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