From 7c8ee5edcd5dc59f1cce3b0af9dd2c4075e51de3 Mon Sep 17 00:00:00 2001 From: David Ashby Date: Thu, 23 Dec 2021 17:44:25 -0700 Subject: [PATCH] day 20 part 2 --- 20/main.go | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/20/main.go b/20/main.go index 183f83a..e30ebab 100644 --- a/20/main.go +++ b/20/main.go @@ -144,22 +144,37 @@ func partOne() { y++ } - img.Print() - fmt.Println(img.CountBrightPixels()) - fmt.Println("") - for i := 0; i < 2; i++ { img = Enhance(img, enhancementString) - img.Print() - fmt.Println(img.CountBrightPixels()) - fmt.Println("") } + fmt.Println(img.CountBrightPixels()) } func partTwo() { scanner := makeScanner(false) - for scanner.Scan() { - // line := scanner.Text() + scanner.Scan() + enhancementString := scanner.Text() + scanner.Scan() // eat empty line + + img := &image{ + background: '.', + grid: map[coord]rune{}, + topleft: coord{0, 0}, } + + y := 0 + for scanner.Scan() { + line := scanner.Text() + img.size = len(line) + for x, c := range line { + img.grid[coord{x, y}] = c + } + y++ + } + + for i := 0; i < 50; i++ { + img = Enhance(img, enhancementString) + } + fmt.Println(img.CountBrightPixels()) }