First attempt at a faster / more efficient implementation. This is orders of magnitude faster than the first, but still not nearly fast enough.

This commit is contained in:
Anna Rose Wiggins 2018-12-13 00:27:02 -05:00
parent fbd7c8fb00
commit 5d4757d4cb
No known key found for this signature in database
GPG key ID: 8D9ACA841015C59A
4 changed files with 102 additions and 0 deletions

27
2018/day12-2.go Normal file
View file

@ -0,0 +1,27 @@
package main
import (
"fmt"
"internal/day12"
"internal/util"
)
const NumGenerations = 50000000000
func main() {
data := util.ReadInput()
plants, rules := day12.FastParseInput(data)
rootIndex := 0
for i := 0; i < NumGenerations; i++ {
plants, rootIndex = day12.FastRunGeneration(plants, rules, rootIndex)
// debug
if i%1000000 == 0 {
fmt.Println("DEBUG: Generation: ", i)
}
}
fmt.Println(day12.FastSumPlants(plants, rootIndex))
}