2019 Day 19 Complete!

This commit is contained in:
Brian Buller 2019-12-23 07:05:56 -06:00
parent eea657e331
commit ac0772f966

View File

@ -54,45 +54,14 @@ func part2(prog []int) {
// Guesses // Guesses
//x, y := 0, 1000 //x, y := 0, 1000
var x, square int var x, square int
bot, _ := 1025, 1037 bot, _ := 1034, 1038
for square != shipSize { for square != shipSize {
bot++ bot++
fmt.Print("Calculating ", bot, "... ") fmt.Print("Calculating ", bot, "... ")
square, x = maxSquare(prog, bot, bot/2) square, x = maxSquare(prog, bot, bot/2)
fmt.Println(square) fmt.Println(square)
} }
fmt.Println(x, bot) fmt.Println(x, (bot+1)-100)
}
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)
} }
func part2Slow(prog []int) { func part2Slow(prog []int) {