2024 Day 17 Complete!

This commit is contained in:
Brian Buller 2024-12-17 11:12:36 -06:00
parent 1e4b9ba2d7
commit 5cfe4e1b65
9 changed files with 762 additions and 0 deletions

141
2024/day16/input Normal file
View File

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

276
2024/day16/main.go Normal file
View File

@ -0,0 +1,276 @@
package main
import (
"errors"
"fmt"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
func main() {
inp := h.StdinToStringSlice()
part1(inp)
// fmt.Println()
// part2(inp)
}
var (
N = h.Coordinate{X: 0, Y: -1}
E = h.Coordinate{X: 1, Y: 0}
S = h.Coordinate{X: 0, Y: 1}
W = h.Coordinate{X: -1, Y: 0}
)
var (
scoreTrack map[h.Coordinate]int
bestCostToEnd map[h.Coordinate]int
)
func part1(inpS []string) {
inp := h.StringSliceToCoordByteMap(inpS)
scoreTrack = make(map[h.Coordinate]int)
bestCostToEnd = make(map[h.Coordinate]int)
start, _ := inp.FindFirst('S')
end, _ := inp.FindFirst('E')
inp.Put(start, '.')
bestCostToEnd[end] = 0
cd := CD{c: start, d: E}
solve(inp, cd, end, 0, []h.Coordinate{cd.c})
best, ok := scoreTrack[end]
if !ok {
panic(errors.New("no path to end found"))
}
fmt.Println("Best Score:", best)
bestSeats := make(map[h.Coordinate]byte)
for i := range bestPaths {
for j := range bestPaths[i] {
bestSeats[bestPaths[i][j]] = byte('0' + i)
}
}
printBestSeats(inp, bestSeats)
fmt.Println("Seats:", len(bestSeats))
}
var bestPaths [][]h.Coordinate
func solve(inp h.CoordByteMap, start CD, end h.Coordinate, score int, currPath []h.Coordinate) int {
// tryMove takes the cd that we're moving to and the cost to move there
// and returns the cost to get from that cd to the end
tryMove := func(c CD, cost int) int {
if inp.ContainsCoord(c.c) && inp.Get(c.c) != '#' {
// printPathMap(inp, c, end, currPath)
// poi := h.Coordinate{X: 3, Y: 10}
// time.Sleep(time.Second / 20)
nextScore := score + cost
v, ok := bestCostToEnd[c.c]
//if c.c.Equals(poi) {
// fmt.Println("Current Scoretrack[poi] =", v)
// fmt.Println("Next Score =", nextScore)
// time.Sleep(time.Second * 5)
//}
if !ok || v >= nextScore {
nxtPath := make([]h.Coordinate, len(currPath))
copy(nxtPath, currPath)
nxtPath = append(nxtPath, c.c)
// Check end conditions
if c.c.Equals(end) {
if !ok || v > nextScore { // New Best
fmt.Println("New Best Path")
scoreTrack[end] = nextScore
bestPaths = [][]h.Coordinate{nxtPath}
} else if v == nextScore { // Another Best Path
fmt.Println("Adding path to best paths")
bestPaths = append(bestPaths, nxtPath)
}
return cost
}
// Not the end, but keep going
scoreTrack[c.c] = nextScore
solve(inp, c, end, nextScore, nxtPath)
}
}
return h.MAX_INT
}
// Test forward
cost := tryMove(start.move(), 1)
// Test CW
if wrk := tryMove(start.turnCW().move(), 1001); wrk < cost {
cost = wrk
}
// Test CCW
if wrk := tryMove(start.turnCCW().move(), 1001); wrk < cost {
cost = wrk
}
bestCostToEnd[start.c] = cost
return cost
}
func printPathMap(inp h.CoordByteMap, loc CD, end h.Coordinate, path []h.Coordinate) {
fmt.Print(h.CLEAR_SCREEN)
wrk := inp.Copy()
wrk.ReplaceAll('.', ' ')
for i := range path {
wrk.Put(path[i], 'o')
}
wrk.Put(loc.c, loc.Byte())
fmt.Println(wrk)
if v, ok := scoreTrack[end]; ok {
fmt.Printf("Best Score: %v (Paths: %d)\n", v, len(bestPaths))
} else {
fmt.Println("Waiting on best score...")
}
}
func printBestSeats(inp h.CoordByteMap, seats map[h.Coordinate]byte) {
fmt.Print(h.CLEAR_SCREEN)
wrk := inp.Copy()
wrk.ReplaceAll('.', ' ')
for k, v := range seats {
wrk.Put(k, byte(0+v))
}
fmt.Println(wrk)
}
/*
func part2(inpS []string) {
inp := h.StringSliceToCoordByteMap(inpS)
scoreTrack = make(map[h.Coordinate]int)
start, _ := inp.FindFirst('S')
end, _ := inp.FindFirst('E')
inp.Put(start, '.')
cd := CD{c: start, d: E}
lookForSeats(inp, cd, end, 0, []h.Coordinate{cd.c})
_, ok := scoreTrack[end]
if !ok {
panic(errors.New("no path to end found"))
}
bestSeats := make(map[h.Coordinate]int)
for i := range bestPaths {
for j := range bestPaths[i] {
bestSeats[bestPaths[i][j]] = i
}
}
fmt.Println("Number of Seats:", len(bestSeats))
}
func coordInPath(c h.Coordinate, path []h.Coordinate) bool {
for i := range path {
if path[i].Equals(c) {
return true
}
}
return false
}
func lookForSeats(inp h.CoordByteMap, start CD, end h.Coordinate, score int, path []h.Coordinate) int {
// Check for finished:
if start.c.Equals(end) {
v, ok := scoreTrack[end]
if !ok || v > score {
// We have a new best path
bestPaths = [][]h.Coordinate{path}
scoreTrack[end] = score
} else if scoreTrack[end] == score {
bestPaths = append(bestPaths, path)
}
return score
}
// Helper func
canMoveTo := func(p h.Coordinate) bool {
return inp.ContainsCoord(p) && inp.Get(p) != '#'
}
// Keep moving:
tryMove := func(c CD, cost int) {
if canMoveTo(c.c) {
// Check if this path has alread gone through this spot
nxtPath := make([]h.Coordinate, len(path))
copy(nxtPath, path)
if coordInPath(c.c, nxtPath) {
return
}
// Ok, now what's the best score we end up if we make this move?
nextScore := score + cost
n, ok := scoreTrack[c.c]
if !ok || n > nextScore {
lookForSeats(inp, c, end, nextScore, append(nxtPath, c.c))
}
}
}
// Test forward
tryMove(start.move(), 1)
// Test CW
tryMove(start.turnCW().move(), 1001)
// Test CCW
tryMove(start.turnCCW().move(), 1001)
return scoreTrack[start.c]
}
*/
type CD struct {
c h.Coordinate
d h.Coordinate
}
func (cd CD) move() CD {
return CD{
c: cd.c.Add(cd.d),
d: cd.d,
}
}
func (cd CD) turnCW() CD {
var newD h.Coordinate
switch cd.d {
case N:
newD = E
case E:
newD = S
case S:
newD = W
case W:
newD = N
}
return CD{
c: cd.c,
d: newD,
}
}
func (cd CD) turnCCW() CD {
var newD h.Coordinate
switch cd.d {
case N:
newD = W
case E:
newD = N
case S:
newD = E
case W:
newD = S
}
return CD{
c: cd.c,
d: newD,
}
}
func (cd CD) Byte() byte {
switch cd.d {
case N:
return '^'
case E:
return '>'
case S:
return 'v'
case W:
return '<'
}
return '?'
}

15
2024/day16/testinput Normal file
View File

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

17
2024/day16/testinput2 Normal file
View File

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

5
2024/day17/examples Normal file
View File

@ -0,0 +1,5 @@
Register A: 0
Register B: 2024
Register C: 43690
Program: 4,0

5
2024/day17/input Normal file
View File

@ -0,0 +1,5 @@
Register A: 33940147
Register B: 0
Register C: 0
Program: 2,4,1,5,7,5,1,6,4,2,5,5,0,3,3,0

220
2024/day17/main.go Normal file
View File

@ -0,0 +1,220 @@
package main
import (
"errors"
"fmt"
"math"
"slices"
"strconv"
"strings"
"time"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
func main() {
inp := h.StdinToStringSlice()
part1(inp)
fmt.Println()
part2(inp)
}
func part1(inp []string) {
vm := InitVM(inp)
fmt.Println("# Part 1")
fmt.Println(run(vm.RegA, vm.RegB, vm.RegC, vm.Prog))
}
func part2(inp []string) {
fmt.Println("# Part 2")
vm := InitVM(inp)
a, b, c, prog := 0, vm.RegB, vm.RegC, vm.Prog
for pos := len(prog) - 1; pos >= 0; pos-- {
a <<= 3
for !slices.Equal(run(a, b, c, prog), prog[pos:]) {
a++
}
}
fmt.Println("Corrected A:", a)
}
func run(a, b, c int, program []int) []int {
out := make([]int, 0)
for ptr := 0; ptr < len(program); ptr += 2 {
oc, oa := program[ptr], program[ptr+1]
value := oa
switch oa {
case 4:
value = a
case 5:
value = b
case 6:
value = c
}
switch oc {
case 0:
a >>= value
case 1:
b ^= oa
case 2:
b = value % 8
case 3:
if a != 0 {
ptr = oa - 2
}
case 4:
b ^= c
case 5:
out = append(out, value%8)
case 6:
b = a >> value
case 7:
c = a >> value
}
}
return out
}
type VM struct {
RegA, RegB, RegC int
Prog []int
ProgStr string
ptr int
Running bool
StdOut []int
StdOutStr string
Debug bool
ProcHistory map[string]bool
Err error
}
func InitVM(inp []string) *VM {
vm := &VM{
ProcHistory: make(map[string]bool),
}
fmt.Sscanf(inp[0], "Register A: %d", &vm.RegA)
fmt.Sscanf(inp[1], "Register B: %d", &vm.RegB)
fmt.Sscanf(inp[2], "Register C: %d", &vm.RegC)
vm.ProgStr = inp[4][9:]
prog := strings.Split(vm.ProgStr, ",")
for i := range prog {
p, _ := strconv.Atoi(prog[i])
vm.Prog = append(vm.Prog, p)
}
return vm
}
func (vm *VM) DetectLoop() {
if _, ok := vm.ProcHistory[vm.String()]; ok {
vm.Err = errors.New("loop detected")
vm.Running = false
}
}
func (vm *VM) Run() {
do := func(op, operand int) {
vm.PrintDebug(op, operand)
switch op {
case 0: // adv (divide A by 2^combo -> int -> A)
vm.RegA = int(float64(vm.RegA) / math.Pow(2, float64(vm.GetVal(operand))))
case 1: // bxl (bitwise XOR of B and literal operand -> B)
vm.RegB = int(vm.RegB ^ operand)
case 2: // bst (combo % 8 -> B)
vm.RegB = int(vm.GetVal(operand) % 8)
case 3: // jnz (if A is = 0 do nothing, else jump ptr to literal operand)
if vm.RegA != 0 {
vm.ptr = operand
}
case 4: // bxc (bitwise XOR of B and C -> B) (reads operand but ignore it)
vm.RegB = vm.RegB ^ vm.RegC
case 5: // out (calc value of combo operand % 8, output that value)
v := vm.GetVal(operand) % 8
vm.StdOut = append(vm.StdOut, v)
if vm.StdOutStr == "" {
vm.StdOutStr = fmt.Sprintf("%d", v)
} else {
vm.StdOutStr = fmt.Sprintf("%s,%d", vm.StdOut, v)
}
case 6: // bdv (exactly like 0, but store into B)
vm.RegB = int(float64(vm.RegA) / math.Pow(2, float64(vm.GetVal(operand))))
case 7: // cdv (exactly like 0, but store into C)
vm.RegC = int(float64(vm.RegA) / math.Pow(2, float64(vm.GetVal(operand))))
}
}
vm.Running = true
for vm.Running {
if vm.ptr >= int(len(vm.Prog)) {
break
}
if vm.Debug {
fmt.Printf("Do: %d %d\n", vm.Prog[vm.ptr], vm.GetVal(vm.Prog[vm.ptr+1]))
}
vm.DetectLoop()
pPtr := vm.ptr
do(vm.Prog[vm.ptr], vm.Prog[vm.ptr+1])
if vm.ptr == pPtr {
vm.ptr = vm.ptr + 2
}
if vm.Debug {
fmt.Println()
fmt.Println(vm)
time.Sleep(time.Second)
}
}
}
func (vm *VM) GetVal(cmb int) int {
switch cmb {
case 4:
return vm.RegA
case 5:
return vm.RegB
case 6:
return vm.RegC
}
return cmb
}
func (vm *VM) PrintDebug(op, b int) {
if !vm.Debug {
return
}
switch op {
case 0:
fmt.Printf("adv (0): %d / int(math.Pow(2, %d)) (A)\n", vm.RegA, vm.GetVal(b))
case 1:
fmt.Printf("bxl (1): %d ^ %d = %d (B)\n", vm.RegB, vm.GetVal(b), (vm.RegB ^ b))
case 2:
fmt.Printf("bst (2): %d %% 8 = %d (B)\n", vm.GetVal(b), vm.GetVal(b)%8)
case 3:
fmt.Printf("jnz (3) if %d != 0; ptr = %d\n", vm.RegA, b)
case 4:
fmt.Printf("bxc (4): %d ^ %d = %d (B)\n", vm.RegB, vm.RegC, (vm.RegB ^ vm.RegC))
case 5:
fmt.Printf("out (5): Output %d\n", (vm.GetVal(b) % 8))
case 6:
fmt.Printf("bdv (6): %d / int(math.Pow(2, %d)) (B)\n", vm.RegA, vm.GetVal(b))
case 7:
fmt.Printf("cdv (7): %d / int(math.Pow(2, %d)) (C)\n", vm.RegA, vm.GetVal(b))
}
}
func (vm VM) String() string {
var ret string
ret = fmt.Sprintf("Register A: %d", vm.RegA)
ret = fmt.Sprintf("%s\nRegister B: %d", ret, vm.RegB)
ret = fmt.Sprintf("%s\nRegister C: %d", ret, vm.RegC)
ret = fmt.Sprintf("%s\n\nProgram: ", ret)
for i := range vm.Prog {
if vm.ptr == int(i) {
ret = fmt.Sprintf("%s[%d],", ret, vm.Prog[i])
} else {
ret = fmt.Sprintf("%s%d,", ret, vm.Prog[i])
}
}
return ret[:len(ret)-1]
}

78
2024/day17/main2.bk Normal file
View File

@ -0,0 +1,78 @@
package main
import (
"fmt"
"slices"
"strconv"
)
func main() {
fmt.Println(day17(1))
fmt.Println(day17(2))
}
func day17(part int) string {
a, b, c, program := parseRegisters()
if part == 1 {
// part 1: run program and return comma-separated output
return fmt.Sprintln(runProgram(a, b, c, program))
}
// part 2: find lowest value of register A that makes the program output itself
a = 0 // the initial value of register A doesnt matter here, so we can reset it
for pos := len(program) - 1; pos >= 0; pos-- {
a <<= 3 // shift left by 3 bits
for !slices.Equal(runProgram(a, b, c, program), program[pos:]) {
a++
}
}
return strconv.Itoa(a) // return a string since part 1 needs a string
}
func parseRegisters() (int, int, int, []int) {
return 33940147, 0, 0, []int{2, 4, 1, 5, 7, 5, 1, 6, 4, 2, 5, 5, 0, 3, 3, 0}
}
func runProgram(a, b, c int, program []int) []int {
out := make([]int, 0)
// for each isntruction pointer
for ip := 0; ip < len(program); ip += 2 {
opcode, operand := program[ip], program[ip+1]
// Process combo operand
value := operand
switch operand {
case 4:
value = a
case 5:
value = b
case 6:
value = c
}
// Execute instruction
switch opcode {
case 0: // adv - divide A by 2^value
a >>= value
case 1: // bxl - XOR B with literal
b ^= operand
case 2: // bst - set B to value mod 8
b = value % 8
case 3: // jnz - jump if A is not zero
if a != 0 {
ip = operand - 2
}
case 4: // bxc - XOR B with C
b ^= c
case 5: // out - output value mod 8
out = append(out, value%8)
case 6: // bdv - divide A by 2^value, store in B
b = a >> value
case 7: // cdv - divide A by 2^value, store in C
c = a >> value
}
}
return out
}

5
2024/day17/testinput Normal file
View File

@ -0,0 +1,5 @@
Register A: 729
Register B: 0
Register C: 0
Program: 0,1,5,4,3,0