Unreasonably Optimized 2019 Day 2

This commit is contained in:
Brian Buller 2019-12-03 09:03:08 -06:00
parent 0d92efbff4
commit 4b016eac64

View File

@ -36,7 +36,7 @@ func part1(prog []int) {
}
}
func slowPart2(prog []int) {
func slowestPart2(prog []int) {
for n := 0; n <= 99; n++ {
for v := 0; v <= 99; v++ {
progcpy := make([]int, len(prog))
@ -63,7 +63,7 @@ func slowPart2(prog []int) {
}
}
func part2(prog []int) {
func slowPart2(prog []int) {
target := 19690720
useN := 0
for n := 0; n <= 99; n++ {
@ -108,6 +108,16 @@ func part2(prog []int) {
}
}
func part2(prog []int) {
target := 19690720
zeroVal := 610685
n := (target - zeroVal) / 360000
target = target % 1000
zeroVal = zeroVal % 1000
v := target - zeroVal
fmt.Println("Answer:", (100*n + v))
}
func printState(prog []int) {
fmt.Println(prog)
}