8 Commits da337ad155 ... a69abd08ae

Author SHA1 Message Date
  Piotr Czajkowski a69abd08ae Added description 3 months ago
  Piotr Czajkowski 8b1beba4d0 Solved part1 3 months ago
  Piotr Czajkowski 363f49d6a0 Not yet 3 months ago
  Piotr Czajkowski 0a89be80ff Able to read input 3 months ago
  Piotr Czajkowski f19cb910ca Added description 3 months ago
  Piotr Czajkowski b3ec084d52 Solved part1 3 months ago
  Piotr Czajkowski ff2c84cfd1 Able to calculate zs 3 months ago
  Piotr Czajkowski d7ea1399ea Able to read input 3 months ago
6 changed files with 4888 additions and 0 deletions
  1. 157 0
      24/code.go
  2. 198 0
      24/description.txt
  3. 313 0
      24/input
  4. 93 0
      25/code.go
  5. 128 0
      25/description.txt
  6. 3999 0
      25/input

+ 157 - 0
24/code.go

@@ -0,0 +1,157 @@
+package main
+
+import (
+	"bufio"
+	"fmt"
+	"log"
+	"os"
+	"slices"
+	"strconv"
+	"strings"
+)
+
+const (
+	AND = iota
+	OR
+	XOR
+)
+
+type Gate struct {
+	id          string
+	left, right string
+	op          int
+	value       int
+}
+
+func readInput(file *os.File) (map[string]Gate, map[string]Gate) {
+	scanner := bufio.NewScanner(file)
+	zs := make(map[string]Gate)
+	gates := make(map[string]Gate)
+
+	readingRegisters := true
+	for scanner.Scan() {
+		line := scanner.Text()
+		if line == "" {
+			if readingRegisters {
+				readingRegisters = false
+				continue
+			}
+
+			break
+		}
+
+		var gate Gate
+		if readingRegisters {
+			parts := strings.Split(line, ": ")
+			if len(parts) != 2 {
+				log.Fatalf("Bad register line: %s", line)
+			}
+
+			gate.id = parts[0]
+
+			n, err := fmt.Sscanf(parts[1], "%d", &gate.value)
+			if n != 1 || err != nil {
+				log.Fatalf("Bad input %s: %s", parts[1], err)
+			}
+		} else {
+			var op string
+			n, err := fmt.Sscanf(line, "%s %s %s -> %s", &gate.left, &op, &gate.right, &gate.id)
+			if n != 4 || err != nil {
+				log.Fatalf("Bad input %s: %s", line, err)
+			}
+
+			switch op {
+			case "AND":
+				gate.op = AND
+			case "OR":
+				gate.op = OR
+			case "XOR":
+				gate.op = XOR
+			}
+
+			gate.value = -1
+		}
+
+		if gate.id[0] == 'z' {
+			zs[gate.id] = gate
+		} else {
+			gates[gate.id] = gate
+		}
+
+	}
+
+	return gates, zs
+}
+
+func calculate(gate Gate, gates map[string]Gate) int {
+	if gate.value != -1 {
+		return gate.value
+	}
+
+	left := calculate(gates[gate.left], gates)
+	right := calculate(gates[gate.right], gates)
+
+	switch gate.op {
+	case AND:
+		gate.value = left & right
+	case OR:
+		gate.value = left | right
+	case XOR:
+		gate.value = left ^ right
+	}
+
+	return gate.value
+}
+
+func zsToNumber(zs map[string]Gate) int64 {
+	arr := make([]byte, len(zs))
+	keys := make([]string, len(zs))
+
+	var index int
+	for key, _ := range zs {
+		keys[index] = key
+		index++
+	}
+
+	slices.Sort(keys)
+	slices.Reverse(keys)
+	for i := range keys {
+		value := zs[keys[i]].value
+		switch value {
+		case 0:
+			arr[i] = '0'
+		case 1:
+			arr[i] = '1'
+		}
+	}
+
+	result, err := strconv.ParseInt(string(arr), 2, 64)
+	if err != nil {
+		log.Fatalf("Can't convert binary %s: %s", arr, err)
+	}
+
+	return result
+}
+
+func calculateZs(zs, gates map[string]Gate) {
+	for key, value := range zs {
+		value.value = calculate(value, gates)
+		zs[key] = value
+	}
+}
+
+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)
+	}
+
+	gates, zs := readInput(file)
+	calculateZs(zs, gates)
+	fmt.Println("Part1:", zsToNumber(zs))
+}

+ 198 - 0
24/description.txt

@@ -0,0 +1,198 @@
+--- Day 24: Crossed Wires ---
+
+You and The Historians arrive at the edge of a large grove somewhere in the jungle. After the last incident, the Elves installed a small device that monitors the fruit. While The Historians search the grove, one of them asks if you can take a look at the monitoring device; apparently, it's been malfunctioning recently.
+
+The device seems to be trying to produce a number through some boolean logic gates. Each gate has two inputs and one output. The gates all operate on values that are either true (1) or false (0).
+
+    AND gates output 1 if both inputs are 1; if either input is 0, these gates output 0.
+    OR gates output 1 if one or both inputs is 1; if both inputs are 0, these gates output 0.
+    XOR gates output 1 if the inputs are different; if the inputs are the same, these gates output 0.
+
+Gates wait until both inputs are received before producing output; wires can carry 0, 1 or no value at all. There are no loops; once a gate has determined its output, the output will not change until the whole system is reset. Each wire is connected to at most one gate output, but can be connected to many gate inputs.
+
+Rather than risk getting shocked while tinkering with the live system, you write down all of the gate connections and initial wire values (your puzzle input) so you can consider them in relative safety. For example:
+
+x00: 1
+x01: 1
+x02: 1
+y00: 0
+y01: 1
+y02: 0
+
+x00 AND y00 -> z00
+x01 XOR y01 -> z01
+x02 OR y02 -> z02
+
+Because gates wait for input, some wires need to start with a value (as inputs to the entire system). The first section specifies these values. For example, x00: 1 means that the wire named x00 starts with the value 1 (as if a gate is already outputting that value onto that wire).
+
+The second section lists all of the gates and the wires connected to them. For example, x00 AND y00 -> z00 describes an instance of an AND gate which has wires x00 and y00 connected to its inputs and which will write its output to wire z00.
+
+In this example, simulating these gates eventually causes 0 to appear on wire z00, 0 to appear on wire z01, and 1 to appear on wire z02.
+
+Ultimately, the system is trying to produce a number by combining the bits on all wires starting with z. z00 is the least significant bit, then z01, then z02, and so on.
+
+In this example, the three output bits form the binary number 100 which is equal to the decimal number 4.
+
+Here's a larger example:
+
+x00: 1
+x01: 0
+x02: 1
+x03: 1
+x04: 0
+y00: 1
+y01: 1
+y02: 1
+y03: 1
+y04: 1
+
+ntg XOR fgs -> mjb
+y02 OR x01 -> tnw
+kwq OR kpj -> z05
+x00 OR x03 -> fst
+tgd XOR rvg -> z01
+vdt OR tnw -> bfw
+bfw AND frj -> z10
+ffh OR nrd -> bqk
+y00 AND y03 -> djm
+y03 OR y00 -> psh
+bqk OR frj -> z08
+tnw OR fst -> frj
+gnj AND tgd -> z11
+bfw XOR mjb -> z00
+x03 OR x00 -> vdt
+gnj AND wpb -> z02
+x04 AND y00 -> kjc
+djm OR pbm -> qhw
+nrd AND vdt -> hwm
+kjc AND fst -> rvg
+y04 OR y02 -> fgs
+y01 AND x02 -> pbm
+ntg OR kjc -> kwq
+psh XOR fgs -> tgd
+qhw XOR tgd -> z09
+pbm OR djm -> kpj
+x03 XOR y03 -> ffh
+x00 XOR y04 -> ntg
+bfw OR bqk -> z06
+nrd XOR fgs -> wpb
+frj XOR qhw -> z04
+bqk OR frj -> z07
+y03 OR x01 -> nrd
+hwm AND bqk -> z03
+tgd XOR rvg -> z12
+tnw OR pbm -> gnj
+
+After waiting for values on all wires starting with z, the wires in this system have the following values:
+
+bfw: 1
+bqk: 1
+djm: 1
+ffh: 0
+fgs: 1
+frj: 1
+fst: 1
+gnj: 1
+hwm: 1
+kjc: 0
+kpj: 1
+kwq: 0
+mjb: 1
+nrd: 1
+ntg: 0
+pbm: 1
+psh: 1
+qhw: 1
+rvg: 0
+tgd: 0
+tnw: 1
+vdt: 1
+wpb: 0
+z00: 0
+z01: 0
+z02: 0
+z03: 1
+z04: 0
+z05: 1
+z06: 1
+z07: 1
+z08: 1
+z09: 1
+z10: 1
+z11: 0
+z12: 0
+
+Combining the bits from all wires starting with z produces the binary number 0011111101000. Converting this number to decimal produces 2024.
+
+Simulate the system of gates and wires. What decimal number does it output on the wires starting with z?
+
+Your puzzle answer was 65635066541798.
+
+The first half of this puzzle is complete! It provides one gold star: *
+--- Part Two ---
+
+After inspecting the monitoring device more closely, you determine that the system you're simulating is trying to add two binary numbers.
+
+Specifically, it is treating the bits on wires starting with x as one binary number, treating the bits on wires starting with y as a second binary number, and then attempting to add those two numbers together. The output of this operation is produced as a binary number on the wires starting with z. (In all three cases, wire 00 is the least significant bit, then 01, then 02, and so on.)
+
+The initial values for the wires in your puzzle input represent just one instance of a pair of numbers that sum to the wrong value. Ultimately, any two binary numbers provided as input should be handled correctly. That is, for any combination of bits on wires starting with x and wires starting with y, the sum of the two numbers those bits represent should be produced as a binary number on the wires starting with z.
+
+For example, if you have an addition system with four x wires, four y wires, and five z wires, you should be able to supply any four-bit number on the x wires, any four-bit number on the y numbers, and eventually find the sum of those two numbers as a five-bit number on the z wires. One of the many ways you could provide numbers to such a system would be to pass 11 on the x wires (1011 in binary) and 13 on the y wires (1101 in binary):
+
+x00: 1
+x01: 1
+x02: 0
+x03: 1
+y00: 1
+y01: 0
+y02: 1
+y03: 1
+
+If the system were working correctly, then after all gates are finished processing, you should find 24 (11+13) on the z wires as the five-bit binary number 11000:
+
+z00: 0
+z01: 0
+z02: 0
+z03: 1
+z04: 1
+
+Unfortunately, your actual system needs to add numbers with many more bits and therefore has many more wires.
+
+Based on forensic analysis of scuff marks and scratches on the device, you can tell that there are exactly four pairs of gates whose output wires have been swapped. (A gate can only be in at most one such pair; no gate's output was swapped multiple times.)
+
+For example, the system below is supposed to find the bitwise AND of the six-bit number on x00 through x05 and the six-bit number on y00 through y05 and then write the result as a six-bit number on z00 through z05:
+
+x00: 0
+x01: 1
+x02: 0
+x03: 1
+x04: 0
+x05: 1
+y00: 0
+y01: 0
+y02: 1
+y03: 1
+y04: 0
+y05: 1
+
+x00 AND y00 -> z05
+x01 AND y01 -> z02
+x02 AND y02 -> z01
+x03 AND y03 -> z03
+x04 AND y04 -> z04
+x05 AND y05 -> z00
+
+However, in this example, two pairs of gates have had their output wires swapped, causing the system to produce wrong answers. The first pair of gates with swapped outputs is x00 AND y00 -> z05 and x05 AND y05 -> z00; the second pair of gates is x01 AND y01 -> z02 and x02 AND y02 -> z01. Correcting these two swaps results in this system that works as intended for any set of initial values on wires that start with x or y:
+
+x00 AND y00 -> z00
+x01 AND y01 -> z01
+x02 AND y02 -> z02
+x03 AND y03 -> z03
+x04 AND y04 -> z04
+x05 AND y05 -> z05
+
+In this example, two pairs of gates have outputs that are involved in a swap. By sorting their output wires' names and joining them with commas, the list of wires involved in swaps is z00,z01,z02,z05.
+
+Of course, your actual system is much more complex than this, and the gates that need their outputs swapped could be anywhere, not just attached to a wire starting with z. If you were to determine that you need to swap output wires aaa with eee, ooo with z99, bbb with ccc, and aoc with z24, your answer would be aaa,aoc,bbb,ccc,eee,ooo,z24,z99.
+
+Your system of gates and wires has four pairs of gates which need their output wires swapped - eight wires in total. Determine which four pairs of gates need their outputs swapped so that your system correctly performs addition; what do you get if you sort the names of the eight wires involved in a swap and then join those names with commas?

+ 313 - 0
24/input

@@ -0,0 +1,313 @@
+x00: 1
+x01: 0
+x02: 1
+x03: 1
+x04: 0
+x05: 0
+x06: 1
+x07: 1
+x08: 0
+x09: 1
+x10: 1
+x11: 1
+x12: 1
+x13: 0
+x14: 1
+x15: 1
+x16: 1
+x17: 0
+x18: 0
+x19: 0
+x20: 0
+x21: 0
+x22: 0
+x23: 1
+x24: 1
+x25: 0
+x26: 0
+x27: 0
+x28: 0
+x29: 0
+x30: 1
+x31: 0
+x32: 0
+x33: 0
+x34: 1
+x35: 1
+x36: 1
+x37: 1
+x38: 0
+x39: 0
+x40: 1
+x41: 1
+x42: 1
+x43: 1
+x44: 1
+y00: 1
+y01: 0
+y02: 0
+y03: 1
+y04: 1
+y05: 0
+y06: 0
+y07: 0
+y08: 0
+y09: 0
+y10: 0
+y11: 1
+y12: 0
+y13: 1
+y14: 0
+y15: 1
+y16: 1
+y17: 0
+y18: 0
+y19: 0
+y20: 1
+y21: 0
+y22: 1
+y23: 0
+y24: 1
+y25: 0
+y26: 0
+y27: 1
+y28: 1
+y29: 1
+y30: 1
+y31: 0
+y32: 1
+y33: 1
+y34: 0
+y35: 0
+y36: 1
+y37: 1
+y38: 1
+y39: 0
+y40: 0
+y41: 0
+y42: 1
+y43: 1
+y44: 1
+
+fcw AND hrn -> jjw
+rhr AND gwd -> rjs
+y24 XOR x24 -> npf
+tnj XOR qqn -> z11
+jfr OR qhf -> jrv
+fgc AND whc -> gdr
+dqm AND dfw -> mmh
+y08 XOR x08 -> rqg
+wvr XOR sfq -> z03
+y26 XOR x26 -> nbq
+x10 XOR y10 -> nvk
+rnc XOR rnf -> z09
+dws AND jkb -> tsk
+x34 AND y34 -> hss
+gkc OR tff -> cfb
+mmh OR vhw -> bqr
+vdj AND hvq -> gkc
+kfp OR hss -> pfd
+hbg AND rwk -> jhc
+y42 AND x42 -> tbv
+hgm OR gwk -> qjk
+jmr AND qts -> fsf
+prk XOR hsj -> z16
+y22 XOR x22 -> wct
+jwd OR fvv -> nbs
+ckj OR kjg -> khc
+dgr XOR rrd -> z33
+x00 AND y00 -> njb
+x08 AND y08 -> dmd
+y15 AND x15 -> knn
+jfk AND vkb -> z29
+y33 XOR x33 -> vvm
+kjp XOR nmj -> z42
+y02 XOR x02 -> vvh
+mgf OR dqq -> bvf
+snd AND sdf -> tvn
+rjd OR tbv -> cvg
+ghp XOR tjc -> z06
+kjp AND nmj -> rjd
+mbg OR ggm -> skg
+wjd OR dtv -> jkb
+x43 XOR y43 -> drs
+qjk AND fck -> dqq
+x38 XOR y38 -> dws
+tkb AND njb -> hfp
+pdf XOR npf -> z24
+x36 XOR y36 -> kvv
+x41 AND y41 -> vhd
+vjw OR hfp -> knm
+kgm OR nkt -> hgw
+y07 AND x07 -> tff
+jjw OR jvf -> ntr
+x41 XOR y41 -> hbg
+x39 XOR y39 -> dfw
+x25 AND y25 -> vwd
+dtp XOR hdp -> z32
+x19 XOR y19 -> rsj
+y43 AND x43 -> tdb
+x05 XOR y05 -> mgj
+y01 AND x01 -> vjw
+y20 XOR x20 -> wpm
+mbs XOR kvv -> z36
+wrd AND djc -> kfp
+x01 XOR y01 -> tkb
+gdr OR wfh -> dtw
+wct AND nbs -> mbg
+qqn AND tnj -> njh
+x17 XOR y17 -> fnw
+rnf AND rnc -> rmd
+bbn AND khc -> kvj
+x02 AND y02 -> qhs
+skg XOR bkg -> z23
+gdf XOR bqr -> z40
+rqg AND cfb -> hgt
+x27 XOR y27 -> kbf
+gdv AND hkd -> qkt
+x14 AND y14 -> ckj
+kvj OR knn -> prk
+tvn OR rhk -> dtp
+fgc XOR whc -> z13
+mjs OR cwb -> rhr
+x09 AND y09 -> tjm
+wpb OR fbj -> z45
+y23 AND x23 -> gsv
+x25 XOR y25 -> cmd
+drs XOR cvg -> z43
+x13 XOR y13 -> whc
+vwd OR qbc -> wpt
+knm XOR vvh -> z02
+y18 AND x18 -> jvf
+y23 XOR x23 -> bkg
+nfm AND nww -> fbj
+rhr XOR gwd -> z28
+fvf OR ncn -> hvq
+cfb XOR rqg -> z08
+bjh OR bcf -> tsf
+dnm XOR nvk -> z10
+y33 AND x33 -> dgr
+y13 AND x13 -> wfh
+wpt AND nbq -> kgm
+y44 XOR x44 -> nww
+hbg XOR rwk -> z41
+tjm OR rmd -> dnm
+y06 AND x06 -> ncn
+y22 AND x22 -> ggm
+sfq AND wvr -> hgm
+bvf AND mgj -> rsn
+vvh AND knm -> fwv
+wpm XOR tsf -> z20
+y31 XOR x31 -> snd
+x04 XOR y04 -> fck
+y42 XOR x42 -> kjp
+dtp AND hdp -> wng
+hgw XOR kbf -> z27
+jmr XOR qts -> fgc
+y21 XOR x21 -> pjs
+x24 AND y24 -> jfr
+wbg OR mtj -> gdv
+pfd AND hrb -> sts
+fsf OR nqs -> z12
+x00 XOR y00 -> z00
+bkj AND fhq -> wjd
+drs AND cvg -> gwc
+rsn OR rfc -> ghp
+x09 XOR y09 -> rnf
+rkd OR gvm -> fhq
+njb XOR tkb -> z01
+jhc OR vhd -> nmj
+wrb XOR dtw -> z14
+y18 XOR x18 -> fcw
+x11 AND y11 -> gpj
+y06 XOR x06 -> tjc
+y12 AND x12 -> nqs
+y29 AND x29 -> wbg
+y16 XOR x16 -> hsj
+nbq XOR wpt -> z26
+x27 AND y27 -> cwb
+y35 XOR x35 -> hrb
+dgr AND rrd -> vtc
+y38 AND x38 -> wms
+tqp OR mjj -> hrn
+pdf AND npf -> qhf
+qkt OR qgt -> sdf
+x28 AND y28 -> jvp
+qgr OR ght -> vmr
+y36 AND x36 -> rkd
+tsk OR wms -> dqm
+x32 AND y32 -> gtw
+gsv OR rvw -> pdf
+y17 AND x17 -> tqp
+nbs XOR wct -> z22
+nvk AND dnm -> cgn
+vmr XOR pjs -> z21
+tsf AND wpm -> qgr
+y03 AND x03 -> gwk
+bqr AND gdf -> npt
+y26 AND x26 -> nkt
+rsj XOR ntr -> z19
+y19 AND x19 -> bcf
+rsj AND ntr -> bjh
+hkd XOR gdv -> z30
+vkb XOR jfk -> mtj
+dmd OR hgt -> rnc
+x16 AND y16 -> gfs
+x04 AND y04 -> mgf
+x40 XOR y40 -> gdf
+y10 AND x10 -> mvg
+y05 AND x05 -> rfc
+y03 XOR x03 -> sfq
+x28 XOR y28 -> gwd
+wrd XOR djc -> z34
+bkj XOR fhq -> dtv
+vdj XOR hvq -> z07
+gpj OR njh -> jmr
+dws XOR jkb -> z38
+vvm OR vtc -> wrd
+jvp OR rjs -> jfk
+y15 XOR x15 -> bbn
+y34 XOR x34 -> djc
+y07 XOR x07 -> vdj
+nkg OR npt -> rwk
+hgw AND kbf -> mjs
+y12 XOR x12 -> qts
+wng OR gtw -> rrd
+jrv XOR cmd -> z25
+pjs AND vmr -> fvv
+bbn XOR khc -> z15
+sts OR skr -> mbs
+x30 AND y30 -> qgt
+y37 XOR x37 -> bkj
+nww XOR nfm -> z44
+bkg AND skg -> rvw
+y32 XOR x32 -> hdp
+qhs OR fwv -> wvr
+x30 XOR y30 -> hkd
+y44 AND x44 -> wpb
+x20 AND y20 -> ght
+y39 AND x39 -> vhw
+dgd XOR fnw -> z17
+tjc AND ghp -> fvf
+y14 XOR x14 -> wrb
+fnw AND dgd -> mjj
+sdf XOR snd -> z31
+mbs AND kvv -> gvm
+x31 AND y31 -> rhk
+x37 AND y37 -> z37
+mgj XOR bvf -> z05
+trs OR gfs -> dgd
+hrb XOR pfd -> z35
+wrb AND dtw -> kjg
+x11 XOR y11 -> qqn
+fcw XOR hrn -> z18
+y35 AND x35 -> skr
+y29 XOR x29 -> vkb
+x40 AND y40 -> nkg
+prk AND hsj -> trs
+cmd AND jrv -> qbc
+gwc OR tdb -> nfm
+qjk XOR fck -> z04
+dqm XOR dfw -> z39
+y21 AND x21 -> jwd
+mvg OR cgn -> tnj

+ 93 - 0
25/code.go

@@ -0,0 +1,93 @@
+package main
+
+import (
+	"bufio"
+	"fmt"
+	"log"
+	"os"
+)
+
+func readLine(line string, arr []int) {
+	for i := range line {
+		if line[i] == '#' {
+			arr[i]++
+		}
+	}
+}
+
+func readInput(file *os.File) ([][]int, [][]int) {
+	scanner := bufio.NewScanner(file)
+	var locks, keys [][]int
+
+	var isKey bool
+	var index int
+	arr := make([]int, 5)
+	for scanner.Scan() {
+		line := scanner.Text()
+		if line == "" {
+			if isKey {
+				keys = append(keys, arr)
+			} else {
+				locks = append(locks, arr)
+			}
+
+			arr = make([]int, 5)
+			index = 0
+			continue
+		}
+
+		if index == 0 {
+			isKey = line[0] == '.'
+		}
+
+		if index != 0 && index != 6 {
+			readLine(line, arr)
+		}
+
+		index++
+	}
+
+	if isKey {
+		keys = append(keys, arr)
+	} else {
+		locks = append(locks, arr)
+	}
+
+	return locks, keys
+}
+
+func countMatches(locks, keys [][]int) int {
+	var count int
+	for _, lock := range locks {
+		for _, key := range keys {
+			fits := true
+			for i := range lock {
+				if lock[i]+key[i] > 5 {
+					fits = false
+					break
+				}
+			}
+
+			if fits {
+				count++
+			}
+		}
+	}
+
+	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)
+	}
+
+	locks, keys := readInput(file)
+	fmt.Println("Part1:", countMatches(locks, keys))
+}

+ 128 - 0
25/description.txt

@@ -0,0 +1,128 @@
+--- Day 25: Code Chronicle ---
+
+Out of ideas and time, The Historians agree that they should go back to check the Chief Historian's office one last time, just in case he went back there without you noticing.
+
+When you get there, you are surprised to discover that the door to his office is locked! You can hear someone inside, but knocking yields no response. The locks on this floor are all fancy, expensive, virtual versions of five-pin tumbler locks, so you contact North Pole security to see if they can help open the door.
+
+Unfortunately, they've lost track of which locks are installed and which keys go with them, so the best they can do is send over schematics of every lock and every key for the floor you're on (your puzzle input).
+
+The schematics are in a cryptic file format, but they do contain manufacturer information, so you look up their support number.
+
+"Our Virtual Five-Pin Tumbler product? That's our most expensive model! Way more secure than--" You explain that you need to open a door and don't have a lot of time.
+
+"Well, you can't know whether a key opens a lock without actually trying the key in the lock (due to quantum hidden variables), but you can rule out some of the key/lock combinations."
+
+"The virtual system is complicated, but part of it really is a crude simulation of a five-pin tumbler lock, mostly for marketing reasons. If you look at the schematics, you can figure out whether a key could possibly fit in a lock."
+
+He transmits you some example schematics:
+
+#####
+.####
+.####
+.####
+.#.#.
+.#...
+.....
+
+#####
+##.##
+.#.##
+...##
+...#.
+...#.
+.....
+
+.....
+#....
+#....
+#...#
+#.#.#
+#.###
+#####
+
+.....
+.....
+#.#..
+###..
+###.#
+###.#
+#####
+
+.....
+.....
+.....
+#....
+#.#..
+#.#.#
+#####
+
+"The locks are schematics that have the top row filled (#) and the bottom row empty (.); the keys have the top row empty and the bottom row filled. If you look closely, you'll see that each schematic is actually a set of columns of various heights, either extending downward from the top (for locks) or upward from the bottom (for keys)."
+
+"For locks, those are the pins themselves; you can convert the pins in schematics to a list of heights, one per column. For keys, the columns make up the shape of the key where it aligns with pins; those can also be converted to a list of heights."
+
+"So, you could say the first lock has pin heights 0,5,3,4,3:"
+
+#####
+.####
+.####
+.####
+.#.#.
+.#...
+.....
+
+"Or, that the first key has heights 5,0,2,1,3:"
+
+.....
+#....
+#....
+#...#
+#.#.#
+#.###
+#####
+
+"These seem like they should fit together; in the first four columns, the pins and key don't overlap. However, this key cannot be for this lock: in the rightmost column, the lock's pin overlaps with the key, which you know because in that column the sum of the lock height and key height is more than the available space."
+
+"So anyway, you can narrow down the keys you'd need to try by just testing each key with each lock, which means you would have to check... wait, you have how many locks? But the only installation that size is at the North--" You disconnect the call.
+
+In this example, converting both locks to pin heights produces:
+
+0,5,3,4,3
+1,2,0,5,3
+
+Converting all three keys to heights produces:
+
+5,0,2,1,3
+4,3,4,0,2
+3,0,2,0,1
+
+Then, you can try every key with every lock:
+
+    Lock 0,5,3,4,3 and key 5,0,2,1,3: overlap in the last column.
+    Lock 0,5,3,4,3 and key 4,3,4,0,2: overlap in the second column.
+    Lock 0,5,3,4,3 and key 3,0,2,0,1: all columns fit!
+    Lock 1,2,0,5,3 and key 5,0,2,1,3: overlap in the first column.
+    Lock 1,2,0,5,3 and key 4,3,4,0,2: all columns fit!
+    Lock 1,2,0,5,3 and key 3,0,2,0,1: all columns fit!
+
+So, in this example, the number of unique lock/key pairs that fit together without overlapping in any column is 3.
+
+Analyze your lock and key schematics. How many unique lock/key pairs fit together without overlapping in any column?
+
+Your puzzle answer was 3395.
+
+The first half of this puzzle is complete! It provides one gold star: *
+--- Part Two ---
+
+You and The Historians crowd into the office, startling the Chief Historian awake! The Historians all take turns looking confused until one asks where he's been for the last few months.
+
+"I've been right here, working on this high-priority request from Santa! I think the only time I even stepped away was about a month ago when I went to grab a cup of coffee..."
+
+Just then, the Chief notices the time. "Oh no! I'm going to be late! I must have fallen asleep trying to put the finishing touches on this chronicle Santa requested, but now I don't have enough time to go visit the last 50 places on my list and complete the chronicle before Santa leaves! He said he needed it before tonight's sleigh launch."
+
+One of The Historians holds up the list they've been using this whole time to keep track of where they've been searching. Next to each place you all visited, they checked off that place with a star. Other Historians hold up their own notes they took on the journey; as The Historians, how could they resist writing everything down while visiting all those historically significant places?
+
+The Chief's eyes get wide. "With all this, we might just have enough time to finish the chronicle! Santa said he wanted it wrapped up with a bow, so I'll call down to the wrapping department and... hey, could you bring it up to Santa? I'll need to be in my seat to watch the sleigh launch by then."
+
+You nod, and The Historians quickly work to collect their notes into the final set of pages for the chronicle.
+
+You don't have enough stars to finish the chronicle, though. You need 13 more.

+ 3999 - 0
25/input

@@ -0,0 +1,3999 @@
+#####
+#####
+#####
+#.##.
+...#.
+.....
+.....
+
+.....
+.#.#.
+.###.
+.###.
+.###.
+.####
+#####
+
+.....
+.....
+.....
+....#
+.#..#
+##.##
+#####
+
+#####
+.####
+.##.#
+.#..#
+.....
+.....
+.....
+
+.....
+.#...
+.#...
+##...
+##...
+###.#
+#####
+
+.....
+.....
+.....
+....#
+#..##
+##.##
+#####
+
+.....
+...#.
+#..#.
+#..#.
+#..#.
+##.#.
+#####
+
+.....
+....#
+..#.#
+.##.#
+.##.#
+.##.#
+#####
+
+#####
+##.##
+##.##
+##..#
+#....
+#....
+.....
+
+.....
+.....
+.....
+#....
+#....
+#.#.#
+#####
+
+.....
+#..#.
+#..#.
+##.#.
+#####
+#####
+#####
+
+.....
+#.#..
+#.#..
+###.#
+###.#
+#####
+#####
+
+.....
+.#.#.
+##.##
+#####
+#####
+#####
+#####
+
+#####
+###.#
+##...
+##...
+#....
+.....
+.....
+
+#####
+.###.
+..#..
+..#..
+.....
+.....
+.....
+
+#####
+#####
+#.#.#
+..#.#
+..#.#
+..#..
+.....
+
+.....
+#....
+#..#.
+#..##
+##.##
+#####
+#####
+
+#####
+##.##
+##.##
+#..#.
+#..#.
+.....
+.....
+
+#####
+##.#.
+.#...
+.....
+.....
+.....
+.....
+
+.....
+.#...
+##...
+##.#.
+####.
+#####
+#####
+
+.....
+#.#.#
+#.###
+#####
+#####
+#####
+#####
+
+.....
+...#.
+.#.#.
+.#.#.
+.#.#.
+.#.#.
+#####
+
+.....
+..#..
+#.#.#
+#.###
+#.###
+#####
+#####
+
+#####
+####.
+####.
+####.
+#.##.
+#.#..
+.....
+
+#####
+.#.##
+.#.#.
+.#.#.
+.#...
+.#...
+.....
+
+#####
+#.###
+#.###
+#..##
+#...#
+#...#
+.....
+
+#####
+##.#.
+#..#.
+#..#.
+...#.
+...#.
+.....
+
+.....
+..#..
+..#..
+.##.#
+.####
+#####
+#####
+
+#####
+.#.#.
+.#.#.
+...#.
+...#.
+...#.
+.....
+
+.....
+...#.
+#..#.
+#..#.
+##.##
+##.##
+#####
+
+#####
+#.###
+...##
+....#
+.....
+.....
+.....
+
+.....
+..#..
+#.#..
+#.#.#
+###.#
+#####
+#####
+
+.....
+.....
+...#.
+#..#.
+#..##
+##.##
+#####
+
+#####
+#####
+##.##
+##.##
+##..#
+.#...
+.....
+
+#####
+#####
+###.#
+###.#
+###..
+#.#..
+.....
+
+.....
+.....
+.#...
+.#...
+.##..
+####.
+#####
+
+.....
+.#..#
+.#..#
+.#.##
+.#.##
+#####
+#####
+
+.....
+.#...
+.##..
+.###.
+####.
+#####
+#####
+
+.....
+.#...
+##...
+##..#
+##..#
+###.#
+#####
+
+.....
+...#.
+.#.#.
+.#.##
+.#.##
+#####
+#####
+
+#####
+.####
+.##.#
+.##..
+.#...
+.#...
+.....
+
+.....
+#..#.
+##.#.
+##.#.
+##.##
+#####
+#####
+
+#####
+#####
+#####
+.#.##
+.#.##
+....#
+.....
+
+#####
+#####
+###.#
+#.#.#
+..#..
+..#..
+.....
+
+.....
+#....
+#...#
+##..#
+###.#
+#####
+#####
+
+.....
+.....
+...#.
+...#.
+.#.#.
+.####
+#####
+
+#####
+#####
+#####
+##.##
+.#..#
+.#..#
+.....
+
+#####
+##.##
+#..##
+...#.
+...#.
+...#.
+.....
+
+.....
+.....
+...#.
+...#.
+..##.
+.####
+#####
+
+#####
+#####
+#.#.#
+#.#.#
+#.#.#
+#.#.#
+.....
+
+#####
+###.#
+###..
+##...
+#....
+#....
+.....
+
+.....
+.#.#.
+####.
+####.
+####.
+#####
+#####
+
+#####
+#####
+##.##
+.#.#.
+.#.#.
+.....
+.....
+
+.....
+.....
+..#..
+#.#.#
+#.#.#
+#.###
+#####
+
+.....
+....#
+....#
+....#
+.#.##
+.#.##
+#####
+
+#####
+##.##
+##.##
+.#.##
+...#.
+...#.
+.....
+
+.....
+..#..
+..#.#
+.####
+.####
+.####
+#####
+
+#####
+####.
+#.##.
+#.##.
+..#..
+..#..
+.....
+
+#####
+#.###
+#.###
+..###
+..##.
+..#..
+.....
+
+.....
+.#...
+.#...
+##.#.
+##.#.
+#####
+#####
+
+#####
+#####
+#####
+####.
+#.##.
+#.#..
+.....
+
+#####
+##.#.
+##...
+.#...
+.#...
+.#...
+.....
+
+#####
+##.##
+##..#
+#...#
+.....
+.....
+.....
+
+#####
+#####
+#.###
+#.#.#
+#.#.#
+.....
+.....
+
+.....
+#....
+#....
+#.#.#
+###.#
+#####
+#####
+
+#####
+#.#.#
+#...#
+#...#
+#...#
+#...#
+.....
+
+.....
+..#..
+..#..
+#.#..
+####.
+#####
+#####
+
+.....
+.#..#
+.#..#
+.#..#
+##.##
+#####
+#####
+
+.....
+....#
+.#..#
+##..#
+##.##
+##.##
+#####
+
+.....
+.....
+....#
+...##
+#.###
+#.###
+#####
+
+.....
+..#..
+..#..
+..#..
+..#..
+#.#.#
+#####
+
+#####
+.##.#
+.#..#
+.#..#
+.#..#
+.....
+.....
+
+#####
+#####
+##.##
+##.##
+##.##
+.#..#
+.....
+
+.....
+.#...
+.#...
+.#..#
+##.##
+#####
+#####
+
+.....
+.....
+...#.
+#.##.
+#.##.
+#.###
+#####
+
+.....
+.....
+#...#
+#.#.#
+#.#.#
+#.###
+#####
+
+.....
+..#..
+..#..
+..#..
+.##.#
+###.#
+#####
+
+.....
+...#.
+.#.#.
+.#.#.
+.#.#.
+.####
+#####
+
+.....
+.....
+.....
+#..#.
+#.###
+#.###
+#####
+
+.....
+.....
+.#..#
+##..#
+##.##
+##.##
+#####
+
+.....
+#.#.#
+#.#.#
+#.#.#
+#.###
+#.###
+#####
+
+.....
+.....
+.#..#
+##.##
+#####
+#####
+#####
+
+#####
+##.##
+##.##
+##.#.
+##.#.
+#....
+.....
+
+.....
+..#..
+..#..
+..#.#
+.####
+#####
+#####
+
+.....
+.....
+.....
+.#.#.
+##.#.
+#####
+#####
+
+#####
+##.##
+#..#.
+...#.
+...#.
+...#.
+.....
+
+#####
+#.##.
+#.##.
+..##.
+..#..
+.....
+.....
+
+#####
+###.#
+###.#
+##..#
+#....
+.....
+.....
+
+#####
+.#.#.
+.#.#.
+...#.
+.....
+.....
+.....
+
+#####
+#####
+.####
+..###
+..#.#
+..#..
+.....
+
+.....
+...#.
+...#.
+#.##.
+####.
+#####
+#####
+
+.....
+.....
+....#
+..#.#
+..###
+.####
+#####
+
+#####
+##.##
+##.##
+.#.##
+.#.##
+.#..#
+.....
+
+.....
+.....
+.....
+.#...
+###..
+###.#
+#####
+
+#####
+#####
+##.##
+.#.##
+...##
+...#.
+.....
+
+.....
+...#.
+...#.
+..###
+.####
+#####
+#####
+
+.....
+#.#..
+#.#..
+###.#
+#####
+#####
+#####
+
+.....
+..#.#
+..#.#
+#.###
+#.###
+#.###
+#####
+
+.....
+.....
+.#.#.
+##.#.
+##.#.
+#####
+#####
+
+#####
+#.###
+#.###
+..##.
+...#.
+.....
+.....
+
+#####
+.####
+.####
+.#.#.
+.#...
+.#...
+.....
+
+#####
+.##.#
+.##.#
+.##..
+.##..
+..#..
+.....
+
+#####
+.####
+.#.##
+.#.#.
+...#.
+.....
+.....
+
+.....
+#....
+#....
+#...#
+##.##
+##.##
+#####
+
+.....
+.....
+.....
+...#.
+.#.#.
+.#.#.
+#####
+
+.....
+.....
+..#..
+..#..
+#.#.#
+#####
+#####
+
+#####
+###.#
+#.#.#
+..#..
+.....
+.....
+.....
+
+#####
+#####
+.#.##
+.#..#
+.#..#
+.#..#
+.....
+
+#####
+####.
+.###.
+.#.#.
+.#.#.
+.....
+.....
+
+#####
+#####
+#.#.#
+#.#.#
+.....
+.....
+.....
+
+#####
+#.###
+#.###
+..###
+..##.
+...#.
+.....
+
+.....
+.#...
+.#.#.
+.#.#.
+.####
+#####
+#####
+
+.....
+...#.
+#..#.
+#..#.
+##.#.
+####.
+#####
+
+.....
+#.#..
+#.#..
+#.#..
+#.#.#
+#.#.#
+#####
+
+.....
+.....
+.#...
+.#...
+.#.#.
+.###.
+#####
+
+.....
+.....
+#....
+#....
+##.#.
+#####
+#####
+
+.....
+.....
+..#..
+..#.#
+#.#.#
+###.#
+#####
+
+#####
+#.##.
+#.##.
+#.#..
+#....
+.....
+.....
+
+#####
+#####
+#.###
+#..##
+#..#.
+#..#.
+.....
+
+.....
+..#..
+..#..
+#.##.
+#.##.
+#####
+#####
+
+#####
+#####
+#####
+.####
+..##.
+...#.
+.....
+
+.....
+..#..
+#.#.#
+###.#
+###.#
+#####
+#####
+
+#####
+###.#
+#.#.#
+#.#.#
+#...#
+#....
+.....
+
+.....
+#..#.
+#..#.
+#.##.
+####.
+#####
+#####
+
+#####
+#####
+#.###
+#.###
+#..##
+#...#
+.....
+
+#####
+#.##.
+..#..
+..#..
+..#..
+..#..
+.....
+
+.....
+#....
+#....
+#....
+#.#.#
+#.###
+#####
+
+#####
+#####
+##.##
+.#.#.
+.#.#.
+.#...
+.....
+
+.....
+..#.#
+..#.#
+#.#.#
+#.#.#
+#.###
+#####
+
+#####
+#.#.#
+....#
+....#
+.....
+.....
+.....
+
+#####
+#####
+.#.##
+.#.#.
+.#.#.
+.#...
+.....
+
+.....
+.....
+..#.#
+#.#.#
+#.#.#
+#.#.#
+#####
+
+#####
+#####
+#####
+.#.##
+.#.#.
+.#...
+.....
+
+#####
+#.###
+#.###
+#.#.#
+....#
+.....
+.....
+
+#####
+#.###
+#.##.
+#..#.
+#....
+#....
+.....
+
+.....
+..#..
+..#.#
+.##.#
+.##.#
+###.#
+#####
+
+#####
+.####
+..#.#
+..#..
+.....
+.....
+.....
+
+.....
+.....
+..#..
+..#..
+..#.#
+#.###
+#####
+
+.....
+#.#.#
+#.#.#
+###.#
+###.#
+#####
+#####
+
+#####
+#####
+.####
+.####
+..#.#
+..#..
+.....
+
+#####
+##.##
+##.##
+##.##
+.#.#.
+.....
+.....
+
+#####
+#.#.#
+#.#..
+#....
+#....
+#....
+.....
+
+.....
+.....
+.....
+..#..
+..##.
+.####
+#####
+
+#####
+####.
+##.#.
+##...
+.#...
+.#...
+.....
+
+.....
+.....
+.....
+.#...
+##.#.
+##.#.
+#####
+
+.....
+.....
+.#.#.
+.#.##
+#####
+#####
+#####
+
+.....
+...#.
+.#.#.
+##.##
+##.##
+#####
+#####
+
+.....
+#....
+##.#.
+#####
+#####
+#####
+#####
+
+#####
+#####
+#####
+#.#.#
+..#..
+.....
+.....
+
+.....
+..#.#
+#.#.#
+#.#.#
+#.###
+#.###
+#####
+
+.....
+.....
+#...#
+#...#
+##.##
+##.##
+#####
+
+#####
+#####
+#####
+#.###
+#..##
+...#.
+.....
+
+#####
+.#.##
+.#.##
+...#.
+...#.
+...#.
+.....
+
+.....
+.#...
+###..
+####.
+####.
+#####
+#####
+
+#####
+###.#
+###.#
+##..#
+##..#
+#....
+.....
+
+#####
+#.#.#
+#.#.#
+#...#
+#....
+#....
+.....
+
+#####
+#####
+#.##.
+#.#..
+.....
+.....
+.....
+
+#####
+#####
+#####
+##.##
+#...#
+#....
+.....
+
+#####
+#####
+#####
+####.
+.###.
+..#..
+.....
+
+.....
+....#
+....#
+#.#.#
+#.#.#
+#####
+#####
+
+.....
+.....
+..#..
+..##.
+..##.
+#.###
+#####
+
+.....
+.#..#
+.#.##
+##.##
+##.##
+##.##
+#####
+
+.....
+.....
+#.#.#
+#.#.#
+###.#
+#####
+#####
+
+.....
+..#..
+.##..
+.##.#
+###.#
+###.#
+#####
+
+#####
+.##.#
+.##.#
+..#.#
+....#
+.....
+.....
+
+.....
+..#..
+#.#..
+#.#.#
+#.#.#
+#.###
+#####
+
+#####
+#####
+#.###
+#.##.
+..#..
+.....
+.....
+
+.....
+.....
+#.#.#
+#.#.#
+#.###
+#####
+#####
+
+.....
+...#.
+#..##
+##.##
+##.##
+##.##
+#####
+
+#####
+#####
+####.
+.##..
+.##..
+..#..
+.....
+
+.....
+.....
+#....
+##...
+##.#.
+##.#.
+#####
+
+#####
+###.#
+###.#
+##..#
+.#..#
+.#..#
+.....
+
+#####
+#####
+##.##
+.#.#.
+.....
+.....
+.....
+
+#####
+####.
+.##..
+.#...
+.#...
+.#...
+.....
+
+.....
+#....
+#..#.
+#.###
+#.###
+#.###
+#####
+
+.....
+....#
+..#.#
+..###
+..###
+#.###
+#####
+
+.....
+....#
+#..##
+#..##
+#.###
+#####
+#####
+
+.....
+..#..
+..##.
+.####
+.####
+#####
+#####
+
+.....
+.....
+.....
+..#..
+#.##.
+#.###
+#####
+
+#####
+#####
+.###.
+.#.#.
+.#...
+.#...
+.....
+
+#####
+#####
+####.
+#.#..
+#.#..
+#....
+.....
+
+#####
+##.#.
+##.#.
+#..#.
+#..#.
+#..#.
+.....
+
+.....
+#..#.
+##.#.
+##.##
+#####
+#####
+#####
+
+#####
+#####
+#####
+#.###
+#.#.#
+..#.#
+.....
+
+.....
+.....
+.....
+..#..
+..#.#
+.##.#
+#####
+
+.....
+....#
+..#.#
+.##.#
+###.#
+###.#
+#####
+
+#####
+#####
+##.#.
+##.#.
+.#.#.
+.#.#.
+.....
+
+#####
+##.##
+.#.##
+.#.##
+...##
+....#
+.....
+
+#####
+.####
+.####
+..###
+..###
+...#.
+.....
+
+#####
+#####
+.##.#
+.##.#
+.##..
+..#..
+.....
+
+#####
+#####
+###.#
+#.#..
+.....
+.....
+.....
+
+#####
+#####
+#.###
+..###
+..#.#
+..#.#
+.....
+
+.....
+#.#.#
+#.#.#
+#.#.#
+#####
+#####
+#####
+
+#####
+#####
+#####
+##.##
+##.#.
+.#...
+.....
+
+.....
+...#.
+..###
+..###
+.####
+.####
+#####
+
+#####
+#.###
+#.###
+#.##.
+#.#..
+#.#..
+.....
+
+.....
+.....
+.....
+.....
+#..#.
+#.###
+#####
+
+#####
+#####
+###.#
+.#..#
+....#
+.....
+.....
+
+.....
+#.#..
+#.#.#
+#.#.#
+###.#
+###.#
+#####
+
+.....
+#...#
+#.#.#
+###.#
+#####
+#####
+#####
+
+.....
+..#..
+#.##.
+#.##.
+#.###
+#####
+#####
+
+#####
+##.##
+.#..#
+.#..#
+....#
+.....
+.....
+
+#####
+#####
+####.
+##.#.
+##.#.
+.#.#.
+.....
+
+#####
+.#.##
+.#.##
+.#.#.
+...#.
+.....
+.....
+
+.....
+.....
+.....
+...#.
+...##
+.#.##
+#####
+
+#####
+.##.#
+..#..
+..#..
+..#..
+..#..
+.....
+
+#####
+#.###
+...##
+...##
+....#
+....#
+.....
+
+#####
+#.###
+#.###
+..#.#
+..#.#
+..#.#
+.....
+
+#####
+#.###
+#.###
+#..#.
+#..#.
+...#.
+.....
+
+#####
+.###.
+.###.
+.##..
+.#...
+.#...
+.....
+
+#####
+##.##
+##.##
+##.##
+#..#.
+.....
+.....
+
+.....
+.#...
+##...
+##...
+##.#.
+####.
+#####
+
+#####
+#####
+.#.#.
+.#...
+.#...
+.....
+.....
+
+#####
+#.###
+#..##
+#...#
+.....
+.....
+.....
+
+.....
+...#.
+..##.
+..##.
+..##.
+#.##.
+#####
+
+#####
+#####
+.##.#
+.#..#
+....#
+....#
+.....
+
+#####
+#.###
+#.##.
+#.##.
+#..#.
+#....
+.....
+
+#####
+.####
+.####
+.####
+.##.#
+..#..
+.....
+
+.....
+.....
+..#.#
+#.#.#
+#.#.#
+###.#
+#####
+
+.....
+.....
+...#.
+.#.#.
+####.
+#####
+#####
+
+.....
+.....
+..#.#
+.##.#
+.##.#
+.####
+#####
+
+.....
+.#...
+###..
+####.
+####.
+####.
+#####
+
+.....
+..#..
+..#..
+#.#..
+#.#..
+####.
+#####
+
+.....
+.....
+#.#..
+#.#..
+###..
+###.#
+#####
+
+#####
+####.
+.###.
+.##..
+.#...
+.....
+.....
+
+#####
+.##.#
+.##.#
+.#..#
+.#..#
+.#..#
+.....
+
+.....
+...#.
+...#.
+#..#.
+##.#.
+##.##
+#####
+
+#####
+#####
+#.###
+#.###
+#.#.#
+....#
+.....
+
+.....
+.....
+.#.#.
+.#.#.
+##.#.
+#####
+#####
+
+.....
+.....
+.#...
+##...
+##...
+##.#.
+#####
+
+#####
+#.###
+#.###
+#.#.#
+#....
+.....
+.....
+
+.....
+.#...
+.#..#
+.#..#
+.##.#
+.##.#
+#####
+
+.....
+.....
+...#.
+..##.
+..##.
+#.###
+#####
+
+.....
+.#..#
+.#..#
+.#.##
+.#.##
+##.##
+#####
+
+#####
+#.##.
+..##.
+..##.
+...#.
+...#.
+.....
+
+.....
+.....
+#..#.
+#.##.
+#.##.
+####.
+#####
+
+#####
+.####
+.####
+.##.#
+.#...
+.....
+.....
+
+#####
+#####
+#.###
+#.##.
+..##.
+...#.
+.....
+
+#####
+.##.#
+..#.#
+..#.#
+..#.#
+.....
+.....
+
+.....
+..#..
+..#..
+..#.#
+#.###
+#.###
+#####
+
+.....
+...#.
+..###
+..###
+#.###
+#####
+#####
+
+.....
+....#
+#..##
+#.###
+#.###
+#.###
+#####
+
+.....
+.#.#.
+.#.##
+.####
+.####
+#####
+#####
+
+.....
+..#.#
+.####
+.####
+.####
+#####
+#####
+
+#####
+#####
+#####
+#.###
+..#.#
+..#..
+.....
+
+#####
+####.
+.###.
+..##.
+..##.
+...#.
+.....
+
+#####
+##.##
+#..#.
+#..#.
+...#.
+.....
+.....
+
+#####
+#####
+####.
+###..
+##...
+.#...
+.....
+
+#####
+#.###
+..###
+..###
+..##.
+...#.
+.....
+
+.....
+#...#
+#.#.#
+#.###
+#####
+#####
+#####
+
+.....
+#....
+#..#.
+#.##.
+#.##.
+#.##.
+#####
+
+#####
+#####
+###.#
+###.#
+##..#
+.#...
+.....
+
+#####
+####.
+.###.
+.#.#.
+...#.
+...#.
+.....
+
+.....
+#..#.
+#..#.
+#..#.
+#..#.
+##.##
+#####
+
+.....
+#....
+##...
+##...
+###.#
+###.#
+#####
+
+.....
+....#
+...##
+...##
+..###
+.####
+#####
+
+#####
+#####
+.##.#
+.##..
+.#...
+.#...
+.....
+
+#####
+##.##
+##.##
+.#.#.
+.#...
+.#...
+.....
+
+#####
+#####
+#####
+###.#
+#.#.#
+..#.#
+.....
+
+#####
+.#.##
+.#.##
+.#.#.
+.#.#.
+.#.#.
+.....
+
+#####
+#####
+#.##.
+..##.
+..##.
+..#..
+.....
+
+.....
+...#.
+.#.#.
+.###.
+.####
+.####
+#####
+
+#####
+#####
+###.#
+###.#
+#.#.#
+#.#.#
+.....
+
+.....
+.....
+.....
+.#.#.
+##.#.
+##.##
+#####
+
+.....
+.....
+...#.
+..##.
+#.##.
+#.##.
+#####
+
+#####
+#####
+###.#
+#.#.#
+..#.#
+.....
+.....
+
+.....
+.....
+.....
+.#..#
+###.#
+#####
+#####
+
+#####
+####.
+##.#.
+#..#.
+#..#.
+#....
+.....
+
+#####
+##.##
+#...#
+#....
+#....
+.....
+.....
+
+#####
+#####
+#####
+#.###
+#..#.
+#..#.
+.....
+
+#####
+#####
+.#.##
+.#.##
+...#.
+...#.
+.....
+
+.....
+.....
+.#...
+.#...
+##.#.
+##.#.
+#####
+
+#####
+#####
+##.#.
+##.#.
+##...
+#....
+.....
+
+.....
+...#.
+...##
+..###
+..###
+.####
+#####
+
+.....
+.....
+..#..
+..#..
+..#..
+.##.#
+#####
+
+.....
+..#..
+.##..
+###.#
+###.#
+###.#
+#####
+
+.....
+#..#.
+#..#.
+##.#.
+##.#.
+####.
+#####
+
+.....
+....#
+#...#
+#..##
+#.###
+#.###
+#####
+
+.....
+.....
+.#..#
+.##.#
+.##.#
+#####
+#####
+
+#####
+#.#.#
+#.#.#
+#...#
+#...#
+.....
+.....
+
+#####
+#####
+####.
+####.
+#.##.
+#..#.
+.....
+
+.....
+.#.#.
+.#.#.
+.#.#.
+.####
+.####
+#####
+
+#####
+#####
+#####
+####.
+##.#.
+#..#.
+.....
+
+#####
+###.#
+.##.#
+.##.#
+..#..
+.....
+.....
+
+.....
+.#...
+.#..#
+.##.#
+.####
+#####
+#####
+
+#####
+####.
+##.#.
+.#.#.
+.#.#.
+.#...
+.....
+
+#####
+###.#
+###.#
+##...
+.#...
+.....
+.....
+
+#####
+##.##
+##.##
+##.##
+##..#
+.#..#
+.....
+
+.....
+..#..
+#.#..
+#.#..
+####.
+####.
+#####
+
+.....
+.....
+....#
+#..##
+##.##
+##.##
+#####
+
+.....
+.....
+.....
+.#..#
+.##.#
+#####
+#####
+
+.....
+.....
+.#...
+.#...
+.#...
+##.#.
+#####
+
+#####
+#.###
+#..#.
+#....
+#....
+.....
+.....
+
+.....
+.#...
+.#..#
+.#..#
+.#.##
+.#.##
+#####
+
+.....
+.#...
+.#..#
+.#.##
+.#.##
+#####
+#####
+
+#####
+#.#.#
+..#.#
+..#.#
+.....
+.....
+.....
+
+.....
+....#
+#...#
+#.#.#
+#.#.#
+#####
+#####
+
+#####
+.####
+..###
+..##.
+...#.
+...#.
+.....
+
+#####
+.####
+.##.#
+.##.#
+.##.#
+..#..
+.....
+
+#####
+.###.
+.##..
+.#...
+.#...
+.#...
+.....
+
+.....
+.#...
+.#...
+##.#.
+##.##
+##.##
+#####
+
+.....
+#....
+#.#..
+#.#.#
+#.###
+#.###
+#####
+
+.....
+.....
+.#...
+.#.#.
+.#.#.
+####.
+#####
+
+#####
+#.###
+..###
+..#.#
+..#.#
+.....
+.....
+
+#####
+#####
+#####
+.####
+.##.#
+.#...
+.....
+
+.....
+.....
+....#
+..#.#
+#.#.#
+#.#.#
+#####
+
+#####
+.#.##
+.#..#
+.#..#
+.#..#
+.#...
+.....
+
+#####
+##.##
+##.##
+.#.##
+....#
+....#
+.....
+
+#####
+#####
+#####
+#####
+#.#.#
+.....
+.....
+
+#####
+#####
+####.
+##.#.
+#..#.
+...#.
+.....
+
+.....
+....#
+#..##
+#..##
+#.###
+#.###
+#####
+
+#####
+###.#
+###.#
+.##.#
+..#.#
+....#
+.....
+
+.....
+....#
+....#
+#..##
+##.##
+##.##
+#####
+
+#####
+####.
+##.#.
+.#.#.
+.#.#.
+...#.
+.....
+
+#####
+.####
+.###.
+..##.
+..#..
+.....
+.....
+
+#####
+#####
+.#.##
+.#.##
+.#.##
+.#.#.
+.....
+
+#####
+.####
+.##.#
+.##.#
+..#..
+.....
+.....
+
+#####
+####.
+##.#.
+#..#.
+...#.
+.....
+.....
+
+.....
+.....
+...#.
+#.###
+#.###
+#####
+#####
+
+.....
+#....
+#..#.
+#..#.
+##.#.
+#####
+#####
+
+#####
+#####
+###.#
+.##.#
+..#.#
+..#..
+.....
+
+#####
+##.#.
+##.#.
+.#.#.
+.#...
+.#...
+.....
+
+.....
+..#..
+..#..
+..#.#
+.##.#
+.####
+#####
+
+.....
+..#..
+..#..
+.##..
+.##.#
+.####
+#####
+
+.....
+..#..
+..#..
+#.#.#
+###.#
+###.#
+#####
+
+#####
+#.###
+..###
+..#.#
+.....
+.....
+.....
+
+.....
+..#..
+#.##.
+#.##.
+#.##.
+#####
+#####
+
+#####
+####.
+###..
+##...
+##...
+#....
+.....
+
+.....
+#....
+##...
+###..
+####.
+####.
+#####
+
+#####
+###.#
+###..
+###..
+.##..
+..#..
+.....
+
+.....
+.....
+.....
+#....
+##...
+###.#
+#####
+
+.....
+#.#.#
+#.#.#
+#.#.#
+###.#
+#####
+#####
+
+.....
+.....
+.....
+.#...
+##...
+###.#
+#####
+
+.....
+....#
+....#
+.#.##
+.#.##
+.####
+#####
+
+.....
+#..#.
+#..##
+#..##
+#..##
+##.##
+#####
+
+#####
+#####
+.#.#.
+...#.
+...#.
+.....
+.....
+
+#####
+###.#
+###.#
+###.#
+##..#
+.#...
+.....
+
+#####
+#####
+##.##
+##..#
+.#..#
+.#...
+.....
+
+#####
+#.###
+#.###
+#.###
+#..#.
+...#.
+.....
+
+#####
+##.##
+.#.##
+.#.#.
+.....
+.....
+.....
+
+.....
+.....
+.....
+.#..#
+.##.#
+.##.#
+#####
+
+#####
+##.##
+##.##
+#..#.
+#..#.
+#....
+.....
+
+#####
+.####
+.##.#
+.##.#
+.#...
+.#...
+.....
+
+#####
+#####
+.####
+.####
+.#.#.
+.#...
+.....
+
+#####
+###.#
+.##.#
+..#.#
+....#
+....#
+.....
+
+.....
+#....
+#..#.
+#.##.
+#.###
+#.###
+#####
+
+#####
+#####
+#####
+#.##.
+..##.
+..#..
+.....
+
+#####
+###.#
+#.#.#
+#.#.#
+#.#.#
+#.#..
+.....
+
+#####
+.###.
+.#.#.
+.#.#.
+...#.
+.....
+.....
+
+#####
+.#.##
+.#.#.
+...#.
+.....
+.....
+.....
+
+#####
+####.
+.###.
+.#.#.
+.#.#.
+.#...
+.....
+
+#####
+#####
+##.##
+##.##
+#..##
+#..#.
+.....
+
+#####
+#.#.#
+..#.#
+.....
+.....
+.....
+.....
+
+.....
+.....
+....#
+....#
+.#..#
+###.#
+#####
+
+#####
+#####
+##.#.
+#..#.
+#....
+#....
+.....
+
+.....
+...#.
+...#.
+..##.
+..###
+.####
+#####
+
+.....
+.....
+...#.
+...#.
+.#.#.
+##.#.
+#####
+
+#####
+.##.#
+.##.#
+.##.#
+.##.#
+..#.#
+.....
+
+#####
+.####
+.###.
+..##.
+...#.
+...#.
+.....
+
+.....
+#....
+#.#..
+#.##.
+#.##.
+#.##.
+#####
+
+.....
+..#..
+..#.#
+..###
+..###
+.####
+#####
+
+.....
+#..#.
+##.#.
+##.#.
+##.#.
+####.
+#####
+
+#####
+#####
+.####
+.##.#
+..#.#
+.....
+.....
+
+.....
+#.#..
+#.##.
+#.##.
+#.##.
+#####
+#####
+
+.....
+.#...
+##..#
+##..#
+###.#
+###.#
+#####
+
+.....
+.....
+.....
+#....
+#.#.#
+#.###
+#####
+
+.....
+.....
+#...#
+#.#.#
+###.#
+###.#
+#####
+
+.....
+...#.
+#..#.
+##.#.
+##.#.
+####.
+#####
+
+#####
+##.##
+#..##
+#...#
+#....
+.....
+.....
+
+#####
+#.###
+..###
+..###
+..#.#
+.....
+.....
+
+.....
+.#...
+.##..
+###..
+####.
+####.
+#####
+
+.....
+..#..
+..#..
+..#..
+..##.
+#.###
+#####
+
+#####
+.####
+.#.##
+...##
+....#
+....#
+.....
+
+.....
+.....
+.#...
+.#...
+.##.#
+.##.#
+#####
+
+#####
+##.##
+##.#.
+##...
+#....
+#....
+.....
+
+#####
+#####
+.####
+..#.#
+..#.#
+..#.#
+.....
+
+.....
+.#...
+.#...
+.#.#.
+##.#.
+#####
+#####
+
+.....
+.....
+.....
+#..#.
+#..#.
+#.###
+#####
+
+.....
+.#.#.
+.###.
+.###.
+.###.
+#####
+#####
+
+#####
+#####
+##.#.
+#....
+#....
+#....
+.....
+
+.....
+.#...
+.#...
+.#..#
+.##.#
+###.#
+#####
+
+.....
+..#..
+.###.
+.###.
+#####
+#####
+#####
+
+.....
+.....
+..#.#
+..#.#
+.##.#
+###.#
+#####
+
+#####
+#####
+#####
+.####
+.#.##
+.#.#.
+.....
+
+#####
+.###.
+.#.#.
+.....
+.....
+.....
+.....
+
+#####
+#####
+#.###
+#.###
+..###
+..#.#
+.....
+
+.....
+#..#.
+#.##.
+#.##.
+####.
+#####
+#####
+
+.....
+..#..
+..#..
+#.#.#
+#####
+#####
+#####
+
+.....
+.....
+....#
+....#
+..#.#
+.##.#
+#####
+
+.....
+#....
+#....
+##..#
+##.##
+#####
+#####
+
+#####
+#####
+#.#.#
+#...#
+#....
+#....
+.....
+
+.....
+.....
+#.#..
+#.#..
+#.#..
+###.#
+#####
+
+.....
+#....
+#....
+##...
+##..#
+###.#
+#####
+
+#####
+###.#
+###.#
+###..
+###..
+#.#..
+.....
+
+.....
+.#...
+##...
+##...
+##..#
+##.##
+#####
+
+.....
+.....
+.....
+..#..
+#.#..
+####.
+#####
+
+#####
+.####
+..###
+..##.
+..#..
+..#..
+.....
+
+.....
+.....
+..#..
+#.#.#
+#.###
+#####
+#####
+
+.....
+.....
+..#..
+#.#..
+#.#.#
+#.###
+#####
+
+#####
+###.#
+.##..
+.##..
+..#..
+..#..
+.....
+
+#####
+#####
+.#.##
+...##
+...##
+....#
+.....
+
+.....
+.....
+.#...
+##...
+##..#
+##.##
+#####
+
+.....
+..#..
+..#..
+..#..
+#.##.
+####.
+#####
+
+#####
+.#.#.
+.#.#.
+.#.#.
+...#.
+...#.
+.....
+
+#####
+#####
+#.###
+#.#.#
+..#.#
+..#.#
+.....
+
+#####
+#####
+#.###
+#.###
+..###
+...#.
+.....
+
+.....
+.....
+.....
+..#..
+#.#..
+#.##.
+#####
+
+#####
+#####
+.##.#
+.#...
+.#...
+.....
+.....
+
+#####
+.##.#
+..#..
+..#..
+.....
+.....
+.....
+
+.....
+...#.
+...#.
+...#.
+..###
+#.###
+#####
+
+#####
+.##.#
+..#.#
+..#..
+..#..
+.....
+.....
+
+#####
+##.##
+##.##
+.#..#
+.#..#
+.#...
+.....
+
+#####
+.##.#
+..#.#
+..#.#
+..#.#
+....#
+.....
+
+#####
+#####
+#####
+.#.##
+.#..#
+.#...
+.....
+
+#####
+#.###
+#..##
+...##
+...##
+....#
+.....
+
+.....
+#....
+#..#.
+#.###
+#####
+#####
+#####
+
+#####
+##.#.
+#....
+#....
+#....
+#....
+.....
+
+.....
+.....
+...#.
+#..##
+#.###
+#.###
+#####
+
+#####
+##.##
+##.##
+##.#.
+.#.#.
+...#.
+.....
+
+.....
+..#..
+#.##.
+####.
+####.
+#####
+#####
+
+#####
+##.#.
+.#.#.
+.#...
+.#...
+.....
+.....
+
+.....
+#...#
+##.##
+##.##
+##.##
+#####
+#####
+
+#####
+#####
+###.#
+#.#.#
+....#
+....#
+.....
+
+.....
+..#..
+..#..
+..##.
+..##.
+#.##.
+#####
+
+.....
+.#...
+.#...
+.##..
+.##.#
+.##.#
+#####
+
+#####
+.####
+..###
+...##
+...##
+....#
+.....
+
+.....
+..#..
+..#..
+..##.
+..###
+.####
+#####
+
+.....
+.#.#.
+.#.#.
+.#.#.
+.#.#.
+.#.##
+#####
+
+.....
+...#.
+...#.
+..###
+#.###
+#.###
+#####
+
+#####
+#.#.#
+#.#.#
+#.#..
+#.#..
+.....
+.....
+
+#####
+#####
+#####
+.##.#
+.##..
+.#...
+.....
+
+#####
+##.##
+##..#
+.#..#
+.#...
+.....
+.....
+
+.....
+....#
+#...#
+#...#
+#...#
+#.#.#
+#####
+
+#####
+####.
+####.
+.###.
+.###.
+.#.#.
+.....
+
+.....
+.....
+....#
+.#..#
+##..#
+##.##
+#####
+
+#####
+##.##
+##.##
+##.##
+##.#.
+.#.#.
+.....
+
+.....
+#.#..
+#.#.#
+#.#.#
+###.#
+#####
+#####
+
+#####
+###.#
+##..#
+##...
+.#...
+.....
+.....
+
+#####
+##.##
+.#.#.
+...#.
+...#.
+...#.
+.....
+
+.....
+#....
+#....
+#..#.
+#..#.
+##.##
+#####
+
+#####
+.##.#
+.##.#
+.##.#
+..#.#
+.....
+.....
+
+#####
+#####
+#####
+##.##
+##.#.
+#....
+.....
+
+.....
+.....
+.....
+...#.
+.#.#.
+#####
+#####
+
+#####
+#####
+#.###
+#.###
+..##.
+..#..
+.....
+
+#####
+###.#
+.##..
+..#..
+..#..
+..#..
+.....
+
+.....
+.#.#.
+##.#.
+##.#.
+##.##
+#####
+#####
+
+.....
+..#.#
+#.###
+#.###
+#####
+#####
+#####
+
+#####
+##.#.
+.#.#.
+.#...
+.....
+.....
+.....
+
+.....
+#....
+#....
+#..#.
+#.##.
+#####
+#####
+
+.....
+....#
+#...#
+#...#
+##..#
+###.#
+#####
+
+.....
+.....
+.#...
+##.#.
+##.#.
+##.#.
+#####
+
+#####
+.###.
+.#.#.
+.#.#.
+.....
+.....
+.....
+
+.....
+.....
+...#.
+.#.##
+##.##
+##.##
+#####
+
+.....
+.....
+#....
+##...
+##.#.
+##.##
+#####
+
+#####
+####.
+###..
+.##..
+..#..
+..#..
+.....
+
+.....
+..#..
+.##..
+.###.
+#####
+#####
+#####
+
+#####
+#.###
+#.###
+#..##
+#..##
+#..#.
+.....
+
+.....
+.....
+...#.
+...##
+...##
+.#.##
+#####
+
+#####
+#####
+#.##.
+#.#..
+#.#..
+.....
+.....
+
+.....
+.#...
+.##..
+.##.#
+.##.#
+###.#
+#####
+
+.....
+#..#.
+#..##
+##.##
+##.##
+##.##
+#####
+
+#####
+#.#.#
+#.#.#
+#.#.#
+#.#..
+#.#..
+.....
+
+.....
+..#..
+.##.#
+.##.#
+#####
+#####
+#####
+
+#####
+#.###
+#.###
+#.#.#
+..#..
+..#..
+.....
+
+.....
+.....
+...#.
+..##.
+..##.
+.###.
+#####
+
+.....
+.....
+.#...
+##..#
+##..#
+###.#
+#####
+
+#####
+#####
+.###.
+.###.
+.##..
+..#..
+.....
+
+.....
+#....
+##...
+##..#
+##..#
+##.##
+#####
+
+#####
+#####
+#####
+#.##.
+#..#.
+.....
+.....
+
+.....
+.#...
+.#...
+##..#
+###.#
+###.#
+#####
+
+.....
+...#.
+...#.
+...##
+#..##
+##.##
+#####
+
+#####
+###.#
+##..#
+##..#
+##..#
+.#...
+.....
+
+.....
+.....
+.#.#.
+.#.#.
+.#.#.
+.#.##
+#####
+
+#####
+#.##.
+#.##.
+#.##.
+#.#..
+..#..
+.....
+
+#####
+#####
+#.##.
+#.##.
+#..#.
+.....
+.....
+
+#####
+#####
+#####
+#####
+###.#
+.#...
+.....
+
+.....
+.....
+#.#..
+###..
+####.
+####.
+#####
+
+#####
+.####
+.####
+..##.
+..#..
+..#..
+.....
+
+.....
+.....
+#.#..
+#.#..
+#.#.#
+###.#
+#####
+
+.....
+.....
+.#...
+.##..
+.###.
+.###.
+#####
+
+.....
+#....
+#.#..
+####.
+####.
+####.
+#####
+
+#####
+##.##
+##.##
+##..#
+.#..#
+....#
+.....
+
+.....
+.....
+..#..
+..#..
+..##.
+#.##.
+#####
+
+#####
+###.#
+.##.#
+.#..#
+....#
+.....
+.....
+
+.....
+#..#.
+##.##
+##.##
+##.##
+#####
+#####
+
+#####
+###.#
+###.#
+.#..#
+.#..#
+.#...
+.....
+
+.....
+.#...
+.##.#
+.##.#
+.####
+#####
+#####
+
+#####
+#####
+###.#
+##..#
+#...#
+#...#
+.....
+
+.....
+.....
+#....
+#...#
+##..#
+##.##
+#####
+
+#####
+##.##
+.#..#
+.#..#
+.#..#
+.#...
+.....
+
+#####
+#####
+###.#
+#.#.#
+#.#.#
+#....
+.....
+
+#####
+##.##
+.#.#.
+.#.#.
+...#.
+.....
+.....
+
+#####
+#####
+#####
+.###.
+..##.
+..#..
+.....
+
+.....
+....#
+..#.#
+.##.#
+.####
+.####
+#####
+
+.....
+.#...
+.#.#.
+.#.#.
+#####
+#####
+#####
+
+.....
+..#.#
+.##.#
+.##.#
+###.#
+#####
+#####
+
+#####
+#####
+##.#.
+#..#.
+#..#.
+...#.
+.....
+
+#####
+##.##
+##.#.
+##.#.
+#....
+.....
+.....
+
+.....
+#....
+#....
+##.#.
+##.#.
+##.#.
+#####
+
+#####
+#####
+###.#
+##..#
+##..#
+#....
+.....