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:
parent
fbd7c8fb00
commit
5d4757d4cb
4 changed files with 102 additions and 0 deletions
27
2018/day12-2.go
Normal file
27
2018/day12-2.go
Normal 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))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue