2019 Day 18 started

This commit is contained in:
Brian Buller 2019-12-18 08:07:19 -06:00
parent 629f47bcf9
commit 7fd8294b2b
2 changed files with 158 additions and 0 deletions

81
2019/day18/input Normal file
View File

@ -0,0 +1,81 @@
#################################################################################
#...#p........#..k........#.K..f........#...#.........#...........#.....#.......#
#.#V#.#######.#P#########.#.#########.###.#.#######.###.###.#####.#.###.#.#####Y#
#.#.#.#.C...#...#....u..#...#.A.....#...#.#.........#...#...#...#.#...#...#.....#
#.#.#.#.###.#########.#.#####.#####.#.#.#.#########.#.###.#####.#.###.#####.#####
#.#...#...#.#.......#.#.#.#...#...#.#.#.#...#...#...#.#...#.....#.....#.#...#...#
#.#####.#.#.###.###.#.#.#.#.###.#.#.#.#.###.#.#.#####.#.###.###########.#.###.###
#...#.#.#.#...#.#.#...#.#.#i#...#.#.#.#.#...#.#.....#.#...#.........#.....#.....#
###.#.#.#.###.#.#.#####.#.#.#.#.#.#.###F#.###.#####.#.###.#######.#.#.#####.###.#
#...#..n#.#.#...#.....#...#.#.#.#.#.#a..#.....#.#...#...#.#.....#.#.#.....#...#.#
#O#######.#.#####.#####.###.#.#.#.#.#.###.#####.#.#.###J#.#.###.#.#######.#####.#
#...#.....#.....#.....#.#...#.#.#.#...#.#.......#.#...#.#.#.#.#.#.........#.....#
###.#.#####.#.###.###.#.#.#####.#######.#.#######.#####.#.#.#.#.###.#######.###.#
#.#.#.#...#.#.....#.#...#.#.....#.......#.#t....#.#.....#l#.#.#...#...#....x#.#.#
#.#.#.###.#.#######.#####.###.###.###.#.###.###.#.#.#####.#.#.###.###.#.#####.#.#
#...#...#.#...#.........#...#....q#...#.#...#...#.#...#.#.#...#...#.#...#...#...#
#.#####.#.###.#.###########I#######.###.#.#####.#.###.#.#.###.#.###.#####.#.#.###
#.......#...#.#.#......z....#...#...#...#.#...#.#.......#.#...#.#.........#.#.#.#
#########.#.#.#.#.###########.#.#.###.###.#.#.#.#.#######.#.###.#.#########G#.#.#
#.....#...#.#...#.#...........#.#.#.#...#.#.#.#.#...#.....#.#...#.....#...#.#...#
#W#.###.###.###.#.#####.#.#####.#.#.###.#.#.#.#.###.#.#####.#.#######.#.###.###.#
#.#...#...#.....#...Z.#.#...#.#...#.#...#...#.#...#.#.....#.#.#.......#.#...#...#
#.###.###.#############.###.#.#####.#.#######.###.#.#####.#.###.#.#####.#.###.###
#...#...#.#.....#.....#...#.#.......#.#.#...#.#.#.#.#.....#...#.#.#...#.....#...#
#.#####.#.#.###.###.#.###.#.#######.#.#.#.#.#.#.#.#.#.###.###.###.#.#.#.#######.#
#.#.....#...#...#...#.#...#...#...#...#.#.#.#.#.#.#.#.#.#.#.#...#.#.#...#.......#
###.###.#####.###.###.#####.#.#.#.#.###.#.#.#.#.#.###.#.#.#.###.#.###.###.#######
#...#.....#.#.#...#.#.#...#.#.#.#.#.....#.#...#.#.....#...#...#.#...#...#.#.....#
#.#######.#.#.###.#.#.#.#.###.#.#.#####.#.#####.#######.#####.#.###.#####.#.###.#
#.#.....#.#.#.....#.#.#.#...#...#...#...#...#.....#...........#...#.........#...#
#.#.###.#.#.#######.#.#.###.#.#####.#.###.#.#.#.###.#########.###.#####.#######.#
#r#...#.#...#.......#.#...#.#.#.....#.#.#.#.#.#.........#...#...#.....#...#...#.#
#.###.#.#####.#.#####.#.#.#.###.#####.#.#.#.###########.#.#.#.#######.#####.#.###
#.....#.#...#.#.#.....#.#.#.....#.....#.#.#.......#...#.#.#.#.#.....#.#.....#...#
#.#####.#.#.#.#.#.#######.#######.#####.#.#######.#.#.###.#.###.###.#.#.#######.#
#.#.#...#.#.#.#.#.#.....#.....#.#.#.....#.#.....#...#.....#...#...#.#...#.......#
#.#.#.###.#.#.#.#.###.#.#.###.#.#.###.#.#.#.###.#############.###.#.#####.#######
#.#.#...#.#...#.#.#...#.#...#.#...#...#.#.#.#...#........m..#...#.#.....#.....#.#
#.#.###.#.#####.#.#.###.#####.#.###.###.#.#.#.###.#########.#.###.#####.#####.#.#
#.....#.......#.....#.........#.....#.......#.....#.........#.........#.........#
#######################################.@.#######################################
#.#...M.........#.H...............#.........#h....#...#.....#.#..............b..#
#.#.###########.#####.###########.#.###.###.#.#.#.#.#.###.#.#.#.###############.#
#.#...........#.......#.........#...#...#...#.#.#...#.#...#.#.......#.D.#.....#.#
#.###########.###.#####.#####.#######.###.###.#.#####.#.###.#########.#.#.###.#.#
#.....#.....#...#.#...#.#...#.....#...#.#.....#.#...#.#.#...#.........#...#.#.#.#
#.###.#.###.###.###.#.#.###.#####.#.###.#######.#.#.#.#.#.###.#############.#.#.#
#...#.#.#.#...#.....#.#.........#...#...#.....#.#.#.#...#.#...#.............#.#.#
#.###.#.#.#.#########.#########.#####.###.###.#.###.#####T#.#.###.#####.#####.#.#
#.#...#...#.....#...#.#.......#...#.....#.#.....#...#...#.#.#...#.....#.......#.#
#.#.###.#####.###.#.#.#.#####.###.#####.#.#######.#.#.###.#.###.#####.#########.#
#.#g....#.....#...#...#...#..d..#.......#...#.#...#.#...#.#...#...#.#.......#...#
#######.#.###.#.#####.#####.###########.###.#.#.#.#.###.#.#######.#.#######.###.#
#.....#.#...#.#.....#.#...#.......#...#.#...#...#.#.....#.....#...#.......#.#...#
#.###.#####.#######.###.#.#.###.###.#.#.#.#######.#.#########.#.#####.#####.#.#.#
#.#.E.....#...#...#.....#.#...#.....#.#.#.#.......#.#.......#...#.....#.....#.#.#
#.#.#####.###.#.#.#######.###.#######.#.#.#.#######.#.#.###.#####.###.#.#####.#.#
#.#.#...#.....#.#.........#...#.....#.#.#.#...#.....#.#...#.#.....#w..#...#..s#.#
#.###.#.#####.#.#.#########.###.###.#.#.#.###.#######.###.###.###.###.###.###.#.#
#.#...#.....#.#.#.#...#.#...#...#...#...#.#...#.......#.#.......#...#...#.....#.#
#.#.#######.#.#.###.#.#.#.###.###.#.#####.#.###.#######.#######.###.#.#########.#
#.#.#.....#.#.#.....#.#...#.#.#...#.....#.#...............#...#...#.#.#.........#
#.#.#.###.#.#.#########.###.#.#.#######.#.###############.#.#####.#.###.#########
#.#.#.#...#.#...#...#...#.....#...#.....#.#...........#...#.#.....#.#...#.......#
#.#.###.#.#.#####.#.#.#########.#.#######.#.#########.#####.#######.#.###.#####.#
#.#.#...#.#.....L.#.#.#.......#.#.......#...#.....#.#...#...#.....#.#.#.......#.#
#.#.#.###.#########.#.#.#####.#.#######.#.###.#.#.#.###.#.###.###.#.#.#######.#.#
#.#.#.#.#.#.......#...#...#...#.#.......#.#.#.#.#.....#.#.#...#...#.#.....#...#.#
#.#.#.#.#.#.###.#.#######.#.#####.#######.#.#.#.#######.#.###.#.###.#####.#.###.#
#.#...#.#.#.#...#.#.......#.#...#....c..#.#...#.#.....#.#.....#.#.......#.#.R.#.#
#.#####.#.###S###.#.#.#####.#.#.#######.#.#####.#.###.#.#######.#.###.###.#####.#
#.......#.....#...#.#.#...#...#.....#...#.....#.#.#...#...#.....#...#...#...#e..#
#.#####.#######B#####.#.###########.#.#######.#.#.#.###.###.#######.###.###.#.#.#
#.....#.........#.....#.....#.....#.#...#...#...#.#...#...#.....#...#.....#.#.#.#
#####.###########.#####.###.#.###.#.###.###.###.#.###.###.#####.#####.###.#.#.#.#
#...#.....#.......#.#.....#.#...#.#...#.#.....#.#.#.......#...#...#...#...#.#.#.#
###.#####.#.#######.#.#####N###.#.###.#.#.#####.#.#######.#.#.###.#.#######.#.#.#
#...#.....#...#..o....#.#...#...#...#...#.#.....#.......#.#j#...#y#.......#.#.#.#
#.###.#######.#.#######.#.###.###.#####.#.#.###########.###.#.###.#.#####.#.#X#.#
#.............#........v#.......#.U.....#.Q...........#.....#.....#.....#.....#.#
#################################################################################

77
2019/day18/main.go Normal file
View File

@ -0,0 +1,77 @@
package main
import (
"bytes"
"errors"
"fmt"
helpers "git.bullercodeworks.com/brian/adventofcode/helpers"
)
var maxX, maxY int
var vault map[helpers.Coordinate]byte
var keys map[helpers.Coordinate]byte
var doors map[helpers.Coordinate]byte
func main() {
file := "input"
if helpers.GetArgNumber(1) != "" {
file = helpers.GetArgNumber(1)
}
inp := helpers.FileToBytes(file)
wrk := bytes.Split(inp, []byte{'\n'})
maxY = len(wrk)
vault = make(map[helpers.Coordinate]byte)
keys = make(map[helpers.Coordinate]byte)
doors = make(map[helpers.Coordinate]byte)
maxX = len(wrk[0])
for y, yv := range wrk {
for x, xv := range yv {
vault[*helpers.NewCoordinate(x, y)] = xv
if isKey(xv) {
keys[*helpers.NewCoordinate(x, y)] = xv
} else if isDoor(xv) {
doors[*helpers.NewCoordinate(x, y)] = xv
}
}
}
PrintVault()
}
func isDoor(b byte) bool {
return b >= 'A' && b <= 'Z'
}
func isKey(b byte) bool {
return b >= 'a' && b <= 'z'
}
func keyToDoor(b byte) byte {
return (b - 'a') + 'A'
}
func doorToKey(b byte) byte {
return (b - 'A') + 'a'
}
func findKey(b byte) (helpers.Coordinate, error) {
var r helpers.Coordinate
if !isDoor(b) {
return r, errors.New("Invalid Door")
}
return r, nil
}
func PrintVault() {
for y := 0; y < maxY; y++ {
for x := 0; x < maxX; x++ {
fmt.Print(string(vault[*helpers.NewCoordinate(x, y)]))
}
fmt.Println()
}
}
func c(x, y int) string {
return fmt.Sprintf("[%d, %d]", x, y)
}