diff --git a/2019/day19/main.go b/2019/day19/main.go index 0fedf6a..70a247c 100644 --- a/2019/day19/main.go +++ b/2019/day19/main.go @@ -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) {