1
0

7 Коммиты 7f4a6f5dd6 ... 894fbfeb7e

Автор SHA1 Сообщение Дата
  Piotr Czajkowski 894fbfeb7e Added description 2 недель назад
  Piotr Czajkowski cc600a3542 Solved part2 2 недель назад
  Piotr Czajkowski 0614f5d3d9 Still not solved 2 недель назад
  Piotr Czajkowski 82461b0acf Solved part1 2 недель назад
  Piotr Czajkowski 45f59886e1 No need to check for edges 2 недель назад
  Piotr Czajkowski b6ae6471a0 Not yet 2 недель назад
  Piotr Czajkowski f41ad9f3d4 Able to read input 2 недель назад
3 измененных файлов с 427 добавлено и 0 удалено
  1. 145 0
      16/code.go
  2. 141 0
      16/description.txt
  3. 141 0
      16/input

+ 145 - 0
16/code.go

@@ -0,0 +1,145 @@
+package main
+
+import (
+	"bufio"
+	"fmt"
+	"log"
+	"os"
+)
+
+type Point struct {
+	y, x      int
+	cost      int
+	direction []int
+	parent    *Point
+}
+
+func (p *Point) key() string {
+	return fmt.Sprintf("%d_%d", p.y, p.x)
+}
+
+func (p *Point) keyWithDirection() string {
+	return fmt.Sprintf("%d_%d_%d_%d", p.y, p.x, p.direction[1], p.direction[0])
+}
+
+func findReindeer(line string, mark byte) *Point {
+	for i := range line {
+		if line[i] == mark {
+			return &Point{x: i}
+		}
+	}
+
+	return nil
+}
+
+func readInput(file *os.File) (*Point, [][]byte) {
+	scanner := bufio.NewScanner(file)
+	var matrix [][]byte
+	var reindeer *Point
+
+	var y int
+	for scanner.Scan() {
+		line := scanner.Text()
+		if line == "" {
+			break
+		}
+
+		matrix = append(matrix, []byte(line))
+		if reindeer == nil {
+			reindeer = findReindeer(line, 'S')
+			if reindeer != nil {
+				reindeer.y = y
+				reindeer.direction = []int{1, 0}
+			}
+
+			y++
+		}
+
+	}
+
+	return reindeer, matrix
+}
+
+var directions [][]int = [][]int{
+	{0, -1}, {1, 0}, {0, 1}, {-1, 0},
+}
+
+func getMoves(reindeer Point, matrix [][]byte) []Point {
+	var moves []Point
+	for _, direction := range directions {
+		move := Point{x: reindeer.x + direction[0], y: reindeer.y + direction[1], cost: reindeer.cost, direction: direction, parent: &reindeer}
+		if matrix[move.y][move.x] != '#' {
+			if reindeer.direction[0] == direction[0] && reindeer.direction[1] == direction[1] {
+				move.cost++
+			} else {
+				move.cost += 1001
+			}
+
+			moves = append(moves, move)
+		}
+	}
+
+	return moves
+}
+
+func hike(reindeer *Point, matrix [][]byte) (int, []*Point) {
+	cost := 1000000000
+	visited := make(map[string]int)
+	paths := make(map[int][]*Point)
+
+	moves := []Point{*reindeer}
+	for len(moves) > 0 {
+		current := moves[0]
+		moves = moves[1:]
+		if matrix[current.y][current.x] == 'E' && current.cost <= cost {
+			cost = current.cost
+			paths[cost] = append(paths[cost], &current)
+		}
+
+		newMoves := getMoves(current, matrix)
+		for _, newMove := range newMoves {
+			if visited[newMove.keyWithDirection()] == 0 || visited[newMove.keyWithDirection()] >= newMove.cost {
+				moves = append(moves, newMove)
+				visited[newMove.keyWithDirection()] = newMove.cost
+			}
+		}
+	}
+
+	return cost, paths[cost]
+}
+
+func countTiles(paths []*Point) int {
+	var count int
+	checked := make(map[string]bool)
+
+	for _, path := range paths {
+		current := path
+		for current != nil {
+			if !checked[current.key()] {
+				checked[current.key()] = true
+				count++
+			}
+
+			current = current.parent
+		}
+	}
+
+	return count
+}
+
+func main() {
+	if len(os.Args) < 2 {
+		log.Fatal("You need to specify a file!")
+	}
+
+	filePath := os.Args[1]
+	file, err := os.Open(filePath)
+	if err != nil {
+		log.Fatalf("Failed to open %s!\n", filePath)
+	}
+
+	reindeer, matrix := readInput(file)
+	lowestCost, bestPaths := hike(reindeer, matrix)
+	fmt.Println("Part1:", lowestCost)
+	fmt.Println("Part2:", countTiles(bestPaths))
+}

+ 141 - 0
16/description.txt

@@ -0,0 +1,141 @@
+--- Day 16: Reindeer Maze ---
+
+It's time again for the Reindeer Olympics! This year, the big event is the Reindeer Maze, where the Reindeer compete for the lowest score.
+
+You and The Historians arrive to search for the Chief right as the event is about to start. It wouldn't hurt to watch a little, right?
+
+The Reindeer start on the Start Tile (marked S) facing East and need to reach the End Tile (marked E). They can move forward one tile at a time (increasing their score by 1 point), but never into a wall (#). They can also rotate clockwise or counterclockwise 90 degrees at a time (increasing their score by 1000 points).
+
+To figure out the best place to sit, you start by grabbing a map (your puzzle input) from a nearby kiosk. For example:
+
+###############
+#.......#....E#
+#.#.###.#.###.#
+#.....#.#...#.#
+#.###.#####.#.#
+#.#.#.......#.#
+#.#.#####.###.#
+#...........#.#
+###.#.#####.#.#
+#...#.....#.#.#
+#.#.#.###.#.#.#
+#.....#...#.#.#
+#.###.#.#.#.#.#
+#S..#.....#...#
+###############
+
+There are many paths through this maze, but taking any of the best paths would incur a score of only 7036. This can be achieved by taking a total of 36 steps forward and turning 90 degrees a total of 7 times:
+
+
+###############
+#.......#....E#
+#.#.###.#.###^#
+#.....#.#...#^#
+#.###.#####.#^#
+#.#.#.......#^#
+#.#.#####.###^#
+#..>>>>>>>>v#^#
+###^#.#####v#^#
+#>>^#.....#v#^#
+#^#.#.###.#v#^#
+#^....#...#v#^#
+#^###.#.#.#v#^#
+#S..#.....#>>^#
+###############
+
+Here's a second example:
+
+#################
+#...#...#...#..E#
+#.#.#.#.#.#.#.#.#
+#.#.#.#...#...#.#
+#.#.#.#.###.#.#.#
+#...#.#.#.....#.#
+#.#.#.#.#.#####.#
+#.#...#.#.#.....#
+#.#.#####.#.###.#
+#.#.#.......#...#
+#.#.###.#####.###
+#.#.#...#.....#.#
+#.#.#.#####.###.#
+#.#.#.........#.#
+#.#.#.#########.#
+#S#.............#
+#################
+
+In this maze, the best paths cost 11048 points; following one such path would look like this:
+
+#################
+#...#...#...#..E#
+#.#.#.#.#.#.#.#^#
+#.#.#.#...#...#^#
+#.#.#.#.###.#.#^#
+#>>v#.#.#.....#^#
+#^#v#.#.#.#####^#
+#^#v..#.#.#>>>>^#
+#^#v#####.#^###.#
+#^#v#..>>>>^#...#
+#^#v###^#####.###
+#^#v#>>^#.....#.#
+#^#v#^#####.###.#
+#^#v#^........#.#
+#^#v#^#########.#
+#S#>>^..........#
+#################
+
+Note that the path shown above includes one 90 degree turn as the very first move, rotating the Reindeer from facing East to facing North.
+
+Analyze your map carefully. What is the lowest score a Reindeer could possibly get?
+
+Your puzzle answer was 98416.
+--- Part Two ---
+
+Now that you know what the best paths look like, you can figure out the best spot to sit.
+
+Every non-wall tile (S, ., or E) is equipped with places to sit along the edges of the tile. While determining which of these tiles would be the best spot to sit depends on a whole bunch of factors (how comfortable the seats are, how far away the bathrooms are, whether there's a pillar blocking your view, etc.), the most important factor is whether the tile is on one of the best paths through the maze. If you sit somewhere else, you'd miss all the action!
+
+So, you'll need to determine which tiles are part of any best path through the maze, including the S and E tiles.
+
+In the first example, there are 45 tiles (marked O) that are part of at least one of the various best paths through the maze:
+
+###############
+#.......#....O#
+#.#.###.#.###O#
+#.....#.#...#O#
+#.###.#####.#O#
+#.#.#.......#O#
+#.#.#####.###O#
+#..OOOOOOOOO#O#
+###O#O#####O#O#
+#OOO#O....#O#O#
+#O#O#O###.#O#O#
+#OOOOO#...#O#O#
+#O###.#.#.#O#O#
+#O..#.....#OOO#
+###############
+
+In the second example, there are 64 tiles that are part of at least one of the best paths:
+
+#################
+#...#...#...#..O#
+#.#.#.#.#.#.#.#O#
+#.#.#.#...#...#O#
+#.#.#.#.###.#.#O#
+#OOO#.#.#.....#O#
+#O#O#.#.#.#####O#
+#O#O..#.#.#OOOOO#
+#O#O#####.#O###O#
+#O#O#..OOOOO#OOO#
+#O#O###O#####O###
+#O#O#OOO#..OOO#.#
+#O#O#O#####O###.#
+#O#O#OOOOOOO..#.#
+#O#O#O#########.#
+#O#OOO..........#
+#################
+
+Analyze your map further. How many tiles are part of at least one of the best paths through the maze?
+
+Your puzzle answer was 471.
+
+Both parts of this puzzle are complete! They provide two gold stars: **

+ 141 - 0
16/input

@@ -0,0 +1,141 @@
+#############################################################################################################################################
+#...#.......#.........#.#...........................#...........#...............#.#.................#.......#.........#.........#.......#..E#
+#.#.#.#.###.#.#.#####.#.#.###.###.#.#################.#######.###.#############.#.#.#.#.#########.###.#####.#.#####.#.###.#######.###.#.#.#.#
+#.........#.#.#.#...#.#.#...#.#.....#.........#.......#.....#.#...#.........#...#.#.#.#.........#.#...#.#...#.#.#...#...#.#.......#...#...#.#
+#######.#.#.###.#.#.#.#.###.#.#######.#######.#.#########.#.#.#.#####.###.###.###.#.#.#########.#.#.###.#.#.#.#.#.#####.#.#.#######.#####.#.#
+#...#...#.#.#...#.#...#...#.#.#.......#.....#.#.#.....#...#.#...#.....#...#...#.....#...#.......#.#.#...#.#.....................#...#.......#
+#.#.#.###.#.#.###.#####.#.#.#.#.#######.###.#.#.#.#.#.#.#########.#########.#####.###.###.#########.#.#.#.#.#########.#.#.#####.#.###.#######
+#.#.#.#...#...#.#...#...#.#.#...#.......#...#...#.#.#.#.........#.....#.....#...#...#.#...#.....#.....#.#.....#...............#.#...#...#...#
+#.#.#.#.###.###.###.#.#.###.#######.###.#.#########.#.#######.#.#####.#.#####.#.###.#.#.#.#.###.#.#####.#.#.###.#######.#####.#.###.###.#.#.#
+#.#.......................#.......#.#.....#.........#...............#.#.......#...#...#.#.#...#.#.#.....#...#...#...#...#.......#...#.#.#.#.#
+#.#########.#.#.#####.###.#######.#.#.#########.#.#################.#.#######.###.###.#.#####.#.#.#.###.#.###.###.#.#.###.#######.###.#.#.#.#
+#...#.........#...#.#...#.....#...#.#.#.......#.#.#...#.......#.....#...#...#...............#.#.#...#.#.#...#.#...#.#...#.#.#.....#...#...#.#
+###.#.#.#####.###.#.###.###.#.#.###.#.###.###.###.###.#.###.###.#####.#.#.#.###.###.#.###.###.#.#####.#.#.#.#.#.###.###.#.#.#.#####.#######.#
+#.........................#.#.#.....#.#...#.#...#...#.#...#...........#.#.#...#...#.#.#.#.....#.#.....#.....#.#.#.....#.#.#.#.....#.#.......#
+#.###.#.#.#.#.#.#####.#####.#.#######.#.###.###.#.#.#.###.###########.###.###.###.#.#.#.#######.#.###.###.#.#.###.#####.#.#.#####.#.#.#######
+#.#.#.#.#.#.#...#...#.#.....#.....#.#...#.....#.#.#.#...#...#...#.....#...#.#.....#.#.........#...#.#.......#...#...#...#.#.#.....#.#.....#.#
+#.#.#.#.#.#.#.###.#.###.#########.#.#########.#.###.###.###.#.#.#######.###.#######.#########.#####.#####.###.#.#.#.#.###.#.#.#####.#####.#.#
+#.#.....#...#.....#.#...#...#.....#...........#.....#.....#.#.#.........#...................#.#.........#.....#.#.#.#.#.....#.#.#.........#.#
+#.#####.#.###.#####.#.#####.#.#######.#######.#######.#####.#.#####.#####.#####.#.###.###.###.#.#######.###.#.#.###.#.#######.#.#.#####.###.#
+#.....#.#.#.......#.#...#...#...#.....#.......#.......#...#.#.#...#...#...#.....#...#...#.#...#.......#.#...#.#...#.....#.....#...#...#.....#
+#.###.#.###.#.#####.###.#.#####.#.###.#.###.#.#.#.###.#.#.#.#.#.#.#.#.#.###.#.#####.###.###.###.#####.#.#.###.###.#####.#.#####.###.#.###.#.#
+#.#...............#.....#.....#.#.#...#.#...#.#.#.#...#.#...#...#.#.#.#...#.........#.#.....#.#...#.#.#...#...#.#.....#...#.....#...#.#.#.#.#
+#.#.###.#.#.#.###.#######.#.###.#.###.#.#.#####.#.#.###.#########.###.#.#.###########.#######.###.#.#.#####.###.#####.###.#####.#.###.#.#.#.#
+#.#.#.#.#.............#...#.....#...#...#...#...#.#...#.#.......#...#...#...#...................#.#.#.#.....#.....#.#...#.#...#.#.#...#.....#
+#.#.#.#.#####.#####.#.#.###########.###.#.#.#.###.###.#.#.#####.###.#.#.###.#.#.###############.#.#.#.#.#####.#.#.#.###.#.#.#.###.#.###.#####
+#.#.#...#...#.......#.#...#.........#.....#.#.#...#...#.#.#.......#.#.#...#.#.#...............#.#.#.#.#.......#.#.#.....#.#.......#...#.#...#
+###.#####.#.#.###########.#.#######.#.#####.#.#.###.###.#.#.#.#####.#.#.###.#.###############.###.#.#.###.#.###.#.###.#.###.###.#.###.###.#.#
+#...#.....#.#.#.........#.#.....#...#.#...#...#.#.#...#.#.#.#.#.....#.#.....#...........#...#.#.....#.#.#...#...#...#.#.....#...#...#...#.#.#
+#.###.#####.#.#.#######.#.#.###.#####.#.#.#####.#.###.#.###.#.#.#####.###########.#####.#.#.#.#.#####.#.###.#.#####.#.#######.#####.###.#.#.#
+#...#...#...#...#.....#.......#.#.....#.#.....#.#.....#.....#.#.....#.........#...#...#...#.#.#.#.....#...#.#.....#.#.......#.....#...#...#.#
+#.#.#.###.###.#.#.###.#####.###.#.#####.#####.#.#######.###.#.#####.#.###.###.#.###.#######.#.#.#.#####.###.#.###.#.#.#####.###.###.#######.#
+#.#.......#...#...#...#...#.....#.#.#...#.#...#.........#...#.#.....#.....#...#...#.......#.#...#.#.......#.#...#.#...#.....#.#.............#
+#######.###.#.#####.###.#.###.#.#.#.#.###.#.###.#########.#.###.###########.###.#.###.###.#.###.#.#######.#.#####.#####.#####.###.#.#.#####.#
+#...#...#...#.#...#.....#.....#.#...#.#...#...#.........#.#.....#.........#.#...#...#.#...#...#.........#.#...#...#.........#.#...#.#.#...#.#
+#.#.#.###.###.#.#.#####.#########.###.#.#.###.#######.###.#######.#######.#.#######.#.#.#####.#######.#.#.###.#.###########.#.#.###.#.#.#.#.#
+#.#...#.....#.........#.#.........#...#.#...#.......#.#...#.....#.#.#...#...........#.#.....#.......#.#.#.......#.....#...#...#.....#...#...#
+#.#####.#######.#####.#.#.#########.#####.#######.#.###.#.#.###.#.#.#.#.#.###.#######.#####.#######.###.#.#######.###.#.###.#########.#.#.###
+#.#.....#.....#.#.....#.#.......#.#.....#.......#...#...#.#.#.#.....#.#...#.#.#...#.....#.#.......#...#.#.#.......#...#...#.#.....#.....#.#.#
+#.#.#####.###.###.#########.###.#.#####.#.#.#####.###.###.#.#.#.#####.#.#.#.#.#.#.#####.#.#.#.#######.#.###.###.#.#.###.#.#.#.###.#.#.#.#.#.#
+#.....#...#.#.....#...........#.....#.....#...#...#...#...#...#...#...#...#...#.#.....#...#.#.#.....#.#...#...#...#.#...#...#...#...#...#.#.#
+#.#####.###.#####.#.###.#.###.#####.#.#######.#.###.#.#######.###.#.###.#######.###.#.#####.###.#.###.###.###.#####.###.#######.#####.#.#.#.#
+#.#.....#.........#.#...#.......#...#.#.....#.......#.#...#...#.......#...........#...#.....#...#...#.....#...#...#...#.......#.#.....#.#...#
+#.#.#########.#####.#.#.#########.###.#.###.###.#######.#.#.###.#####.#############.###.#####.#####.###.###.###.#.###.#####.###.#####.#.###.#
+#.#.........#.......#.#.#...#...#.#.....#...#.....#.....#.........#.......#.#.....#...#.#.........#.#...#...#...#...#.#.........#.....#.....#
+#.#########.###.#.###.#.#.#.#.#.#.#.#####.#.#.###.#.###.#########.#.#####.#.#.###.###.#.#.#######.#.#.###.###.#.#.#.#.#.###.#.###.###.#.#.###
+#.#...#.....#...#...#.#.#.#.#.#...#...#...#.#...#.#.#.#...#...#...#...#.....#.#.#.....#.......#.......#...#...#.#.#...#...#.#.......#...#...#
+#.#.#.#.#####.#####.#.#.#.#.#.#######.#.#####.###.#.#.#.#.#.#.#.###.#.#.#####.#.###.#########.#.#.#####.#######.#.#.###.#.###.#######.#.#.###
+#...#...#...#.#...#.#...#.#...#.....#.#.....#.#...#.#.#.#...#.#.#...#.#.#.....#...#.#.....#.#.#.#.....#.#.....#.#.#...#.#.#...#.#...#.#.....#
+###.#.###.#.#.#.#.#.#.###.#######.#.#.#####.#.#.###.#.#.#####.#.#####.#.#.#####.#.#.#.###.#.#.#.#######.#.###.#.#.###.###.#.###.#.#.#.###.#.#
+#...#.#...#...#.#...#.....#.....#.#.......#...#...#.#.#.#.....#.......#.#...#...#.#.#.#.#.#.#.#.#.......#.#...#.#.#...#...#.....#.#.....#.#.#
+#####.#.#######.#.#########.###.#.###.#########.#.#.#.#.#.###########.#.###.#.#.#.#.#.#.#.#.#.#.#.###.###.#.###.###.###.###.###.#.###.#.#.#.#
+#.....#.#.......#.............#...#...#.......#.#.#.#.#.#.#.........#...#...#...#...#...#.#.#.#.#...#.#...#.#.#...#.....#.......#.#.......#.#
+#.###.#.#.#######.###########.#######.#.#####.###.#.#.#.#.#.#.###.###.###.###.#########.#.#.#.#.###.###.###.#.#.#.#####.#.#######.###.###.#.#
+#.#.....#.#...#.#.....#.....#.#.....#.#.#...#.#...#.#.#.#.#.....#.....#.#.......#.....#.#.#.......#.....#...#.#.#.......#...#...#.....#...#.#
+#.#.#####.#.#.#.#####.###.###.#.###.###.###.#.#.#.#.#.#.#.#.###.#######.#.#####.#.###.#.#.#######.#######.###.#.###########.###.#####.#.#.#.#
+#.#.....#...#.#...........#...#.#.......#...#.#.#.#.#...#.#.#.......#...#.....#.#.....#.#.....#.#.........#...#...#...#.....#...#.....#...#.#
+#.#.#######.#.#####.#######.#.#.#########.###.#.###.#.#.#.#.#.#####.#.###.###.#.###.#.#.#####.#.#####.#.###.#.###.###.#.#####.###.#######.#.#
+#.#.#.......#.....#...#.....#.#.....#.....#.....#.....#.#.#...#.......#...#...#.....#.....#...#.#...#.#.#...#...#.....#.......#...#...#...#.#
+#.#.#.###.#######.#####.#####.#####.#.###.#.#####.#####.#.###########.#.###.###############.###.#.#.#.#.#.#.#######.###.#######.###.#.#.#.#.#
+#.#.#...#...#.....#.....#...#.#...#.#.#...#.#.....#.....#.#...........#...#.................#...#.#.#.#.#.#...#...#.#...#.......#.#.#...#...#
+#.###.#.#.#.#.#####.###.#.#.###.#.#.###.###.#.#####.#.###.#.#######.#.#.#.###################.###.#.#.#.#####.#.#.#.#.###.#######.#.#####.#.#
+#.....#...#.#...#.....#.#.#...#.#.#...#.....#.....#.#...#.#.#...........#.#.........#.....#.......#...#.....#.#.#.#.#.#.#...#.#.............#
+#.#####.#.#.###.###.#.###.#.#.#.#.###.#.#########.#.###.#.#.#.###########.#.#.#####.#####.#.#.#############.#.#.#.#.#.#.###.#.#.#########.#.#
+#...............#...#.......#...#...#.#.#.#.........#...#...#.....#...#...#.#.#...#.......#.....#.....#.....#.#.#...#.#.#...#...#.#...#...#.#
+###.#####.#.#.###.#.#.#####.#.###.#.#.#.#.#.#########.#############.#.###.#.#.#.#.#######.#####.###.#.#.#.###.#.#####.#.#.###.###.#.#.#.#.###
+#...#.....#.#.....#.#.#.......#...#...#...#...#.......#.............#...#...#.#.#.#...#.........#...#.#.#.#.....#.#...#.#.#...#...#.#...#...#
+#.###.#.#.#.#######.#.###.###.#.#####.###.###.#.###.###.###############.###.#.#.#.#.#.#####.#.#.#.###.#.#.#.#####.#.###.#.###.#.###.###.#.#.#
+#...#.......#...#...#...#...#.......#.#.....#.#.#...#...#.........#...#...#.#.....#.#.....#.#...#.#.#.#...#.......#...#.#...#...#...#...#...#
+#.#.#.#.#.###.#.#.#####.###.#######.#.#######.#.###.#.###.###.#.###.#.###.#.#####.#.#####.#.#####.#.#.#.#.#####.#####.#.###.#####.#.#.#.#.#.#
+#.#.#.........#.#.#...#.#...#.......#.#...#...#...#.#.#.#.#...#.#...#...#.#.#...#.......#...#.....#...#.#.#.....#...#.....#.......#...#.#.#.#
+#.#.###.#.#######.#.###.#.#.#.#####.#.#.#.#.#####.#.#.#.#.#.#####.#####.#.###.#.#######.#######.###.###.#.#######.#.#.#.#########.#.#.#.#.#.#
+#.#.#.............#.......#.#.#...#.#.#.#...#.....#.#.#...#.....#...#.#.#.....#.......#.........#.#...#.#.......#.#...#...#.....#.....#...#.#
+###.###.#.#.#######.#########.#.###.#.#.#####.#.#####.#.#######.###.#.#######.#######.#.#########.###.#.#######.#.#####.#.#.###.###.###.###.#
+#...#.......#...#.....#...#...#.#...#...#...#.#.#.....#.......#.#...........#...#...#.......#...#...#...#...#.#.#.....#.#.#...#...#.....#.#.#
+#.###.#.#####.#.#.#####.#.#.###.#.#######.#.#.#.#.###########.#.#.#####.###.###.#.#####.###.#.#.###.###.#.#.#.#.#.###.#.#.###.#.#.#.###.#.#.#
+#.#...#.......#.#.#...#.#.#...#.#.#.......#...#.#.#.....#.....#.#.#.....#.#.#.....#.........#.#...#...#...#...#.......#.#.#...#.....#.......#
+#.#.###.###.###.#.#.#.#.#.###.#.#.#.#.#.#.#.###.#.#.###.#######.#.#.#####.#.#######.#########.###.#.#########.#.#.#.#.#.#.#.###.###.###.#####
+#.#.......#.#...#.#.#...#.....#...#.#.#...#.#...#.......#.....#.#...#.....#.........#...#.......#.#.........#.#...#.#.#.#.....#.#.....#...#.#
+#.#######.#.#.###.#.###.#######.###.#.#####.#.#######.###.###.#.#####.#################.#.#####.#.#######.#.#.###.###.###.###.#.#.###.#.#.#.#
+#...#.....#.#.....#.#...#...#.#.#...#...#...#.........#...#...#.....#...#.......#.....#...#.............#.#.....#...#.#...#.#.....#...#.#.#.#
+#.###.#####.#######.#####.#.#.#.#######.#.#####.#########.#.###.###.#.#.#.###.#.#.#.#.#####.#.#########.###.#######.#.#.#.#.###.###.###.#.#.#
+#.....#...#...#...#.#.....#.#.......#...#.#...#...........#.#.....#.#.#.......#...#.#.......#.........#...#.#.....#.....#.....#.....#...#...#
+#.#####.#.###.#.#.#.#.#####.###.###.#.###.###.#.#.#########.#.#####.#.#############.#########.#####.#####.#.#.#.#.#######.#.###.###.#.#.###.#
+#.#.....#.....#.#.#.......#.....#.....#.#.....#.#.........#.#.....#.....#.........#.#...#...#.#...#.#...#.#.#.#.#...#.......#...#.....#...#.#
+#.###########.###.#######.#####.#######.#####.#.#########.#.#.#.#.#######.#####.#.#.#.#.#.#.#.###.#.#.#.#.#.#.#.###.#########.###.#.#####.#.#
+#...........#.....#...#...#...#.......#.......#.........#.#.#.#.#.......#...#.......#.#...#.#.....#...#...#.#.#.#...#.......#.#.....#...#.#.#
+###########.#######.#.#.###.#.#######.###########.#.#.###.#.###.#######.#.#.#####.#######.#.#####.###########.#.#.###.#####.#.###.#.#.#.###.#
+#...#.....#...#.....#.#...#.#.....#.#.#...........#...#...#.#...#.....#.#.#.....#.......#.#.....#.#.....#...#.#.#...#.#...#.#...#.#...#...#.#
+#.#.#.#.#.###.#.#####.###.###.###.#.#.#.#######.#.###.#.###.#.#######.#.#####.#.#.#.###.#.#.###.#.###.#.#.#.#.#.###.#.#.#.#.#.#.#.#.#####.#.#
+#.#.#...#...#.#.#...#.........#.....#.#.#.....#.#.#...#.#...#.#.......#.....#.#.......#.#.#.#...#.#...#...#.#.#...#...#.#.#.#.#.#.#.....#.#.#
+#.#.###.###.#.#.#.#.###.###.#######.#.#.#.#####.#.#.###.#.#.#.#.#####.#####.###.#######.#.#.#####.#.#######.#.#.#.#####.#.#.#.#.###.###.#.#.#
+#.#.#...#.#...#...#...#...#.....#...#.#...#.....#.......#.#...#...........#...#.........#.#.#.....#...#.#.....#.#.......#.#.#.#.....#.#.#...#
+#.#.#.#.#.#######.###.###.###.#.#.###.#.###.#####.#.#.###.#####.###.###.#.###.###.#######.#.#.#####.#.#.#.###########.###.#.#####.#.#.#.#.###
+#.#.#.#...#.....#...#...#.....#.#.#.#...#...#.....#.#.#...#.........#.#.#...#.....#.#.....#.#.#.....#.#...#.......#...#...#.....#.....#.#...#
+#.#.#.#.#.#.###.###.###.#######.#.#.#####.###.#####.#.#.#.#.#.#####.#.#.###.#######.#.#####.#.#######.#####.#####.#.###########.#.#.#.#.#.#.#
+#.#.#.#.#...#...#.....#.#.......#.......#...#...#...#.#.#...#.#.....#.#...#.....#.......#...#.......#.......#.....#.....#.....#.#...#.#.#.#.#
+###.#.#.#####.#######.#.#.#############.###.#.###.###.#######.#.#####.###.#######.#######.#########.#######.#.#####.###.#.#.#.#.#.#.#.#.#.#.#
+#...#...#...#.#.....#.#.#.......#.......#...#.#...#...#.......#.#.......#.#.......#...#...#.......#.#.....#.#.#.....#.#...#.#.#.#.#.#.#.#.#.#
+#.#####.#.#.#.#.###.#.#.#######.###.#####.#.###.###.###.###.#.#.#.#####.#.#.#####.#.#.#.###.#####.#.#.###.###.#####.#.#####.#.#.#.#.#.#.#.#.#
+#.......#.#...#.....#.#.#.....#...#.#.....#.#...#.......#.....#.#.#.....#...#.......#.#.....#.#...#...#.#...#.....#.#.........#...#.#.#.#...#
+#.###.#.#.#####.#.###.#.#.###.###.#.#.#.#####.###.###.#####.###.#.###############.###.#######.#.#######.###.#.###.#.###.###.#.###.#.#.#.###.#
+#...#.#.#.......#.#...#.......#...#...#.#.....#.#.#.......#.#...#...............#.#.........#.#.......#...#.#...#.#...#.#...#.......#.#.....#
+###.#.#.#########.#.#########.#.#.#.#####.#####.#.#######.#.#.###.###########.#.#.#########.#.#####.###.#.#.#.###.###.###.#.#####.###.###.#.#
+#.#.#.#...#.....#.#.......#...#...#.#...#.....#.#.......#.#.#.#.........#.#...#.#.....#...#.......#.....#...#.#...#.#...#.#.#.......#...#.#.#
+#.#.#.#.#.#####.#.#########.#####.#.#.#.#####.#.#.#####.#.#.#.#########.#.#.###.#.###.#.#.#######.#############.###.###.#.###.###.#.###.#.#.#
+#.....#.#.#.....#.........#.#...#.#...#.#...#.#.#.......#.#.#...#.....#...#.#.#.......#.#.......#...#...........#...#...#.........#...#.#.#.#
+#####.#.#.#.###.#########.#.#.#.#.#.###.#.#.#.#.#.#.#####.#.###.#.###.#####.#.#.#.#####.#######.###.#####.#.#####.###.#######.###.#.#.#.#.#.#
+#...#.#.....#...#.......#...#.#...#...#...#...#.#.....#...#...#...#...#.....#.#.#.....#.......#...#.#.......#.....#...#.........#.#.#.#.#.#.#
+#.#.#.#.#########.###.#######.###.#########.#.#.#####.#.###########.###.#####.#.#.###.#####.#####.#.#.#######.###.#.###.#######.#.#.###.#.###
+#.#...#...........#.#.......#...#...........#.........#.#.........#.#...#.....#.#...#.....#.#.....#...#...#...#.#.#...#.#.....#.#.#.....#...#
+#.#####.###########.#######.#.#.###########.#########.#.#.#####.###.#.#######.#.#########.#.#.###.#####.#.#.###.#.###.#.#####.#.#.#########.#
+#.....#.#.#...........#.....#.#.........#...#.........#...#...#.#...#.#.......#.........#.#.#...#.#.....#...#...#...#...#.....#.#.#.....#.#.#
+#.###.#.#.#.#.#####.###.###.#.#####.#####.###.#########.###.#.#.#.###.#.#.###.#########.#.#####.###.#########.#.###.#####.#.###.#.#.###.#.#.#
+#.#...#.#...#.....#.#...#...#.....#.....#...#...#.....#...#.#.#...#.....#...#.......#...#.....#.....#.......#.#...#.......#.#...#.#.#.....#.#
+###.#.#.#.###.###.#.#.#####.#####.#####.###.###.#.###.###.#.#######.#.#####.#.#######.#######.#.#####.#.###.#.#.#########.#.#.###.#.#######.#
+#...#.#.#...#.#.....#.....#...#...#...#.....#...#.....#...#.......#.#.......#.#.....#.#.......#.#.........#...#.#.......#.#.#.#.#.#.#.....#.#
+#.###.#.###.#.#.#.#.#####.#####.#####.#######.#####.#.#.#######.#.#.#####.#.###.###.#.#.#######.#.#########.#.#.#.#####.#.#.#.#.#.#.#.###.#.#
+#.#...#.#.#.....#.#.....#.......#.......#.........#.#.........#.#...#.#.......#...#.#...#.....#.#.....#...#...#.....#...#.....#.....#.#.#.#.#
+#.#####.#.###.###.###.#####.#####.#####.#####.###.#.#.#######.#.#####.#.#####.###.#.#######.###.###.###.#.###########.#########.#####.#.#.#.#
+#.....#.#.........#.#.......#.....#.........#.#...#.........#.#.......#...#...#...#.......#...#.#.#.#...#.......#...#.#...#...#...#...#...#.#
+#.###.#.#.###.#####.###.###.#####.#########.###.#####.#.#####.#######.###.#.#.#.###.#####.#.#.#.#.#.#.#########.#.#.#.#.#.#.#.###.#.###.###.#
+#...#.#.#.#...........#.#.#.....#.....#.........#.....#.#...#.#.....#...#.#.#.#...#...#.#.#.#.#.#.#.#.#.....#...#.#.#...#...#...............#
+###.#.#.#.#.#.#########.#.#####.#.###.###.#########.#####.#.#.#.#.#.###.#.#.###.#####.#.#.#.#.#.#.#.#.#####.#.###.#.#####.#####.#.#.#########
+#...#...#.#.....#...............#...#.......#...#...#.....#.#.#.#.#.#...#.#.....#.....#...#.#.#.....#.....#...#...#.....#.#...#.#.#.........#
+#.#######.#.#.#.#.###.###.###########.#####.#.#.#.#.#.#####.#.#.#.#.#.###.###.#.#.#######.###.#.###.#####.#.###.#######.#.#.###.#.#########.#
+#.#.....#.#.#...#...#.....#...#.....#.#.......#.#.#.#.....#...#.#.#.#.#.#.......#.#.....#.....#...#...#...#.#.....#.....#.#.#...#.#.......#.#
+#.#.###.#.###.#.###.#.###.#.#.#.###.#.#.#.#####.#.#######.#####.#.###.#.#####.#.#.#.###.#####.#.#.#####.###.#.###.#.#####.#.#.#.#.#.#######.#
+#...#.#.#.#...#...#.....#.#.#.#.#.#.....#.#.....#.......#.....#.#...#.#.....#.#.#.#...#.#.......#.......#...#.#...#...#.....#.#.#.#.#.....#.#
+#####.#.#.#.#.###.###.#.#.#.#.#.#.###.###.#.#######.###.#####.#.###.#.#.#####.#.#.###.#.#######.#########.#####.#####.#######.#.#.#.#.###.#.#
+#.#.....#...#...#.....#.#...#...#.........#.....#...#.#...#...#...............#.#.....................#...#.....#.....#.....#.#.#.#...#...#.#
+#.#.#########.#.#####.#.#.#####.#####.###.#.###.#.###.###.#.#.#######.#.#.#.#.#.#######.#######.#######.###.#####.#####.###.#.#.#.#####.###.#
+#.#.#.........#...#.......................#...#.#...#...#.#...#.....#.#.#.....#.....#.........#.#...#...#...#.....#...#.#.....#.#.......#...#
+#.#.#.#.#####.###.#.#.#.###.#.###.###.#.#.#####.#.#.###.#.###.#.###.#.#.###.#.#####.#.#####.#.#.#.#.#.###.###.#####.#.#.###############.#.###
+#.#.#.#.#.....#...#...#.....#.........................#.#...#.#...#.#...#...#.....#...........#...#...#.....#.......#.#.#...#.....#.....#...#
+#.#.#.#.#.#####.###############.#####.#.#########.###.#.#.###.###.#.#####.#.#.###.#.###.#.#.#.#.#######.###.#########.#.#.#.#.###.#.#######.#
+#...#.#.#...#...#...............#...#.#...#.....#...#.#...#...#...#.......#.............#.#.#...........#...#...#...#.#...#.....#.#.......#.#
+#.###.#.###.#.###.#.#.#.#####.###.#.#.###.#.###.###.#.###.#.#.#.###########.#.#####.#.###.#####.#######.#.###.###.#.#.#.#######.#.#####.###.#
+#...#.#.#...#.#...#.................................#...#.#.#.....#...#...#.#.#.#...#...#.....#.......#.#...#.....#...#.......#.#.......#...#
+###.###.#.###.#####.#.#.#.###.#.#####.###.#.#.###.#####.###.#.###.#.###.#.#.#.#.#.###.#.#####.#.#####.#####.#.#############.#.###########.#.#
+#S......#...........#...#.......#...........#.........#...........#.....#.....#.......#.........#...........#...............#.............#.#
+#############################################################################################################################################