2019 Day 19 Complete!

main
Brian Buller 2019-12-23 07:05:56 -06:00
parent eea657e331
commit ac0772f966
1 changed files with 2 additions and 33 deletions

View File

@ -54,45 +54,14 @@ func part2(prog []int) {
// Guesses
//x, y := 0, 1000
var x, square int
bot, _ := 1025, 1037
bot, _ := 1034, 1038
for square != shipSize {
bot++
fmt.Print("Calculating ", bot, "... ")
square, x = maxSquare(prog, bot, bot/2)
fmt.Println(square)
}
fmt.Println(x, bot)
}
func part2Almost(prog []int) {
shipSize := 100
// Guesses
x, y := 0, 1000
var square int
bot, top := 1026, 1037
square, x = maxSquare(prog, y, 0)
lastCheckRow := y
for {
if square > shipSize {
y = y - (y-bot)/2
} else if square < shipSize {
y = y + (top-y)/2
}
if lastCheckRow == y {
break
}
lastCheckRow = y
fmt.Print("Calculating at ", y, "... ")
square, x = maxSquare(prog, y, (y / 2))
if square > 100 && y < top {
top = y
} else if square < 100 && y > bot {
bot = y
}
fmt.Println("Square:", square)
}
fmt.Println("Final Square:", square)
fmt.Println(x, y)
fmt.Println(x, (bot+1)-100)
}
func part2Slow(prog []int) {