2020 Day 19 & 20 Complete
This commit is contained in:
1728
2020/day20/input
Normal file
1728
2020/day20/input
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,9 @@ func init() {
|
||||
}
|
||||
for y := range monster {
|
||||
for x := range monster[y] {
|
||||
SeaMonster[h.Coordinate{X: x, Y: y}] = monster[y][x] == '#'
|
||||
if monster[y][x] == '#' {
|
||||
SeaMonster[h.Coordinate{X: x, Y: y}] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,12 +60,8 @@ func solve(inp []string, part int) {
|
||||
for x := range image[y] {
|
||||
if image[y][x] {
|
||||
waves++
|
||||
fmt.Print("#")
|
||||
} else {
|
||||
fmt.Print(" ")
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
fmt.Println("## Part2\nAnswer:", waves)
|
||||
}
|
||||
@@ -200,11 +198,6 @@ func buildMapFromTiles(tiles map[int]*Tile) [][]bool {
|
||||
func monsterSlayer(inp [][]bool) [][]bool {
|
||||
var found bool
|
||||
for r := 0; r < 8; r++ {
|
||||
if r == 6 {
|
||||
// This is the correct orientation
|
||||
fmt.Println("Rotation:", r)
|
||||
PrintMap(inp)
|
||||
}
|
||||
for y := range inp {
|
||||
for x := range inp[y] {
|
||||
match := true
|
||||
@@ -232,7 +225,6 @@ func monsterSlayer(inp [][]bool) [][]bool {
|
||||
}
|
||||
}
|
||||
if found {
|
||||
fmt.Println("Found, breaking")
|
||||
break
|
||||
}
|
||||
if r&1 == 0 {
|
||||
@@ -284,3 +276,39 @@ func PrintMap(inp [][]bool) {
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func PrintCoordMap(m map[h.Coordinate]bool) {
|
||||
minX := h.MAX_INT
|
||||
maxX := h.MIN_INT
|
||||
minY := h.MAX_INT
|
||||
maxY := h.MIN_INT
|
||||
|
||||
for k := range m {
|
||||
if k.X < minX {
|
||||
minX = k.X
|
||||
}
|
||||
if k.X > maxX {
|
||||
maxX = k.X
|
||||
}
|
||||
if k.Y < minY {
|
||||
minY = k.Y
|
||||
}
|
||||
if k.Y > maxY {
|
||||
maxY = k.Y
|
||||
}
|
||||
}
|
||||
for y := minY; y <= maxY; y++ {
|
||||
for x := minX; x <= maxX; x++ {
|
||||
if v, ok := m[h.Coordinate{X: x, Y: y}]; ok {
|
||||
if v {
|
||||
fmt.Print("#")
|
||||
} else {
|
||||
fmt.Print(".")
|
||||
}
|
||||
} else {
|
||||
fmt.Print(".")
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
107
2020/day20/testinput
Normal file
107
2020/day20/testinput
Normal file
@@ -0,0 +1,107 @@
|
||||
Tile 2311:
|
||||
..##.#..#.
|
||||
##..#.....
|
||||
#...##..#.
|
||||
####.#...#
|
||||
##.##.###.
|
||||
##...#.###
|
||||
.#.#.#..##
|
||||
..#....#..
|
||||
###...#.#.
|
||||
..###..###
|
||||
|
||||
Tile 1951:
|
||||
#.##...##.
|
||||
#.####...#
|
||||
.....#..##
|
||||
#...######
|
||||
.##.#....#
|
||||
.###.#####
|
||||
###.##.##.
|
||||
.###....#.
|
||||
..#.#..#.#
|
||||
#...##.#..
|
||||
|
||||
Tile 1171:
|
||||
####...##.
|
||||
#..##.#..#
|
||||
##.#..#.#.
|
||||
.###.####.
|
||||
..###.####
|
||||
.##....##.
|
||||
.#...####.
|
||||
#.##.####.
|
||||
####..#...
|
||||
.....##...
|
||||
|
||||
Tile 1427:
|
||||
###.##.#..
|
||||
.#..#.##..
|
||||
.#.##.#..#
|
||||
#.#.#.##.#
|
||||
....#...##
|
||||
...##..##.
|
||||
...#.#####
|
||||
.#.####.#.
|
||||
..#..###.#
|
||||
..##.#..#.
|
||||
|
||||
Tile 1489:
|
||||
##.#.#....
|
||||
..##...#..
|
||||
.##..##...
|
||||
..#...#...
|
||||
#####...#.
|
||||
#..#.#.#.#
|
||||
...#.#.#..
|
||||
##.#...##.
|
||||
..##.##.##
|
||||
###.##.#..
|
||||
|
||||
Tile 2473:
|
||||
#....####.
|
||||
#..#.##...
|
||||
#.##..#...
|
||||
######.#.#
|
||||
.#...#.#.#
|
||||
.#########
|
||||
.###.#..#.
|
||||
########.#
|
||||
##...##.#.
|
||||
..###.#.#.
|
||||
|
||||
Tile 2971:
|
||||
..#.#....#
|
||||
#...###...
|
||||
#.#.###...
|
||||
##.##..#..
|
||||
.#####..##
|
||||
.#..####.#
|
||||
#..#.#..#.
|
||||
..####.###
|
||||
..#.#.###.
|
||||
...#.#.#.#
|
||||
|
||||
Tile 2729:
|
||||
...#.#.#.#
|
||||
####.#....
|
||||
..#.#.....
|
||||
....#..#.#
|
||||
.##..##.#.
|
||||
.#.####...
|
||||
####.#.#..
|
||||
##.####...
|
||||
##..#.##..
|
||||
#.##...##.
|
||||
|
||||
Tile 3079:
|
||||
#.#.#####.
|
||||
.#..######
|
||||
..#.......
|
||||
######....
|
||||
####.#..#.
|
||||
.#...#.##.
|
||||
#.#####.##
|
||||
..#.###...
|
||||
..#.......
|
||||
..#.###...
|
Reference in New Issue
Block a user