1
0
Fork 0

Compare commits

...

5 commits

Author SHA1 Message Date
6164e1edee
Some stuff 2024-12-17 12:05:03 -05:00
3a8e1ba1a9
Print some debug stuff 2024-12-17 08:52:46 -05:00
4633a84ae1
part 1 working and prep part 2 2024-12-17 01:25:41 -05:00
19147d460c
Part 1 2024-12-17 01:13:47 -05:00
e584957eb7
Day sixteen 2024-12-17 00:23:05 -05:00
4 changed files with 368 additions and 0 deletions

141
16/input Normal file
View file

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

109
16/main.rb Executable file
View file

@ -0,0 +1,109 @@
#!/usr/bin/env ruby
require "debug"
require "matrix"
@input = (ARGV.first.nil? ? DATA : ARGF)
.readlines(chomp: true)
.map(&:chars)
start = [@input.flatten.index { _1 == "S" }]
.map { Vector[_1 / @input.size, _1 % @input.first.size] }
.first
finish = [@input.flatten.index { _1 == "E" }]
.map { Vector[_1 / @input.size, _1 % @input.first.size] }
.first
NORTH = Vector[-1, 0]
EAST = Vector[0, +1]
SOUTH = Vector[+1, 0]
WEST = Vector[0, -1]
DIRECTIONS = [NORTH, EAST, SOUTH, WEST]
class PriorityQueue < Array
alias extract_min shift
alias peek first
def <<(v)
unless v.is_a?(Array)
raise ArgumentError, "PriorityQueue requires array with priority as last"
end
super
sort_by!(&:last)
end
end
def dijkstra(graph, start, start_direction, target)
dist = Hash.new # scores
prev = Hash.new
queue = PriorityQueue.new
queue << [start, start_direction, 0]
dist[[start, start_direction]] = 0
# alternate only inserting source and add nodes inside score check later
until queue.empty?
position, direction, score = queue.extract_min
neighbors = DIRECTIONS.each do |new_direction|
neighbor = position + new_direction
next if neighbor == position || graph.dig(*neighbor) == "#"
new_score = score + 1 + (direction == new_direction ? 0 : 1) * 1_000
if dist[[neighbor, new_direction]].nil? || new_score < dist[[neighbor, new_direction]]
dist[[neighbor, new_direction]] = new_score
prev[[neighbor, new_direction]] = [[position, direction]]
queue << [neighbor, new_direction, new_score]
elsif new_score == dist[[neighbor, new_direction]]
prev[[neighbor, new_direction]] << [position, direction]
end
end
end
return dist, prev
end
def seats(dist, prev, target)
visited, queue = Array.new, Array.new
lowest_score = dist.keys.select { |(pos, dir)| pos == target }.map { dist[_1] }.min
dist
.select { |(position, _), score| position == target && lowest_score == score }
.each { queue << _1.first }
until queue.empty?
directional_location = queue.pop
visited << directional_location.first
unless prev[directional_location].nil?
queue.concat(prev[directional_location])
end
end
return visited.uniq
end
dist, prev = dijkstra(@input, start, EAST, finish)
part_1 = dist.keys.select { |(pos, dir)| pos == finish }.map { dist[_1] }.min
p part_1
part_2 = seats(dist, prev, finish)
p part_2.size
__END__
###############
#.......#....E#
#.#.###.#.###.#
#.....#.#...#.#
#.###.#####.#.#
#.#.#.......#.#
#.#.#####.###.#
#...........#.#
###.#.#####.#.#
#...#.....#.#.#
#.#.#.###.#.#.#
#.....#...#.#.#
#.###.#.#.#.#.#
#S..#.....#...#
###############

5
17/input Normal file
View file

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

113
17/main.rb Executable file
View file

@ -0,0 +1,113 @@
#!/usr/bin/env ruby
require "debug"
DEBUG = false
input = (ARGV.first.nil? ? DATA : ARGF)
.readlines(chomp: true)
split = input.index("")
registers = input[...split]
.map { _1.split(": ") }
.map(&:last)
.map(&:to_i)
.zip(%i[A B C])
.map(&:reverse)
.to_h
program = input[split+1]
.split(" ")
.last
.split(",")
.map(&:to_i)
OPERANDS = [
->() { 0 }, ->() { 1 }, ->() { 2 }, ->() { 3 },
->() { registers[:A] },
->() { registers[:B] },
->() { registers[:C] },
->() { :noop },
]
def execute(registers, program)
stdout, commands = Array.new, Array.new
ic = 0
while ic < program.size
opcode = program[ic]
literal_operand = program[ic+1]
combo_operand = OPERANDS[literal_operand].call
ic += 2
case opcode
when 0
numerator = registers[:A]
denominator = 2 ** combo_operand
registers[:A] = numerator / denominator
commands << [:adv, numerator, denominator]
when 1
registers[:B] = registers[:B] ^ literal_operand
commands << [:bxl, literal_operand]
when 2
registers[:B] = combo_operand % 8
commands << [:bst, combo_operand % 8]
when 3
if registers[:A] == 0
commands << [:noop]
else
ic = literal_operand
commands << [:jnz, literal_operand]
end
when 4
registers[:B] = registers[:B] ^ registers[:C]
commands << [:bxc, registers[:B], registers[:C]]
when 5
stdout << combo_operand % 8
commands << [:out, combo_operand % 8]
when 6
numerator = registers[:A]
denominator = 2 ** combo_operand
registers[:B] = numerator / denominator
commands << [:bdv, numerator, denominator]
when 7
numerator = registers[:A]
denominator = 2 ** combo_operand
registers[:C] = numerator / denominator
commands << [:cdv, numerator, denominator]
end
end
if DEBUG
commands.each { puts _1.join(" ") }
end
[registers, program, stdout.join(",")]
end
part_2 = registers[:A].dup
_, _, part_1 = execute(registers, program)
p part_1
while true
part_2 += 100_00
registers = {A: part_2, B: 0, C: 0}
_, _, output = execute(registers, program)
p "#{part_2} (a): #{output}"
break if output.match?(/4,1,5,5,0,3,3,0$/)
end
while part_2 <<= 3
registers = {A: part_2, B: 0, C: 0}
_, _, output = execute(registers, program)
next if output.size < 31
p "#{part_2} (b): #{output}"
raise if output.size > 31
end
__END__
Register A: 2024
Register B: 0
Register C: 0
Program: 0,3,5,4,3,0