diff --git a/2024/day16/input.txt b/2024/day16/input.txt new file mode 100644 index 0000000..2e1e1ec --- /dev/null +++ b/2024/day16/input.txt @@ -0,0 +1,141 @@ +############################################################################################################################################# +#.............#...#...........#...#...................#.........#...........#...................................#.............#.......#....E# +#.#####.#####.#.#.#.###.#####.#.#.#.#.#########.#####.#.#######.#.#########.#######.###.###.###.#.#######.#.###.#.#########.#.#####.#.#.#.#.# +#.#...#...#.#...#.#...#.....#.#.#.#.#.....#.....#...#...#.......#...#.....#.....#...#.#.....#.#.#.#.....#.#...#.#.#.#.......#...#...#.#.#.#.# +###.#.#.#.#.###.#.###.#.###.#.#.#.#.#.###.#.#####.#######.#########.###.#######.#.###.#######.#.#.#####.#.###.#.#.#.#.#########.#.###.#.#.#.# +#...#.#.#.#...#.....#...#...#...#...#.#.#...#...#.......#.........#...#.........#.#.#.........#.#.......#.#...#.#.#.#.....#.....#.#...#.#.#.# +#.###.###.#.###.#########.#####.#####.#.#####.#.#.#.#############.#.#.#####.#####.#.#.###.###.#.###.#####.#.###.#.#.#####.###.###.#.###.#.### +#.#.......#.....#.....#...#.....#.....#.......#...#.............#.#.#.....#.#.....#.#...#...#.#.#...#.....#.#.#.#.....#.#...#...#.#.#...#...# +#.#########.###.#.#.###.###.###.#.#####.#################.#######.#.#####.#.#.#####.###.###.#.#.###.#.#####.#.#.#####.#.###.###.#.###.#.#.#.# +#.#...#.....#.#...#...#.#.#.#.#.#.........#.............#...#.....#.....#.#.#...#...#...#...#.#...#.#.#...#...#...........#.#.............#.# +#.#.#.#####.#.#.#####.#.#.#.#.#.#######.#.#.#######.###.###.#.#######.###.#.###.#.#.#.#.#.###.###.###.#.#.###.###########.#.#.#####.###.#.#.# +#...#.....#...#...#...#.#.#...#.........#...#.....#...#.#...#...#.#...#...#.....................#...#...#...#.......#...#.#.#.#.......#.#...# +#.#######.#####.###.#.#.#.#.#####.#####.#####.###.#####.#.#####.#.#.###.#########.#.#.#.###.#######.#.#.#.#####.#####.#.#.#.###.#.#####.#.### +#.#.....#.....#.#...#.#.#...#.....#...#.#.#...#.....#...#.....#.#...#...#.........#.#.....#.#.......#...#.......#.....#.#.#...#...#.....#...# +#.#.###.###.#.#.#.###.#.#.###.#####.#.#.#.#.#######.#.#######.#.###.#.###.###########.#.###.#.###########.#######.###.#.#.###.#.#.#.###.#.#.# +#...#.#.#...#...#.#...#.#...#.#.....#.#...#.....#.#...#.......#...#.#.#.#.......#.....#...#...#.........#...#.....#.#...#...#.#.#...#.....#.# +#####.#.###.#####.#.###.#####.#.###.#.#.#.#####.#.#.#####.###.###.###.#.#.#####.#.#####.#.#.###.#######.#####.#####.#.###.###.#.#.###.#####.# +#.....#.....#.....#...#.#.....#...#.#.#.....#.......#...#...#.#...#...#...#.......#.....#.#.#...#.............#.....#.#.#.#...#.#.#...#...#.# +#.#########.#.#######.#.#.#########.###.#####.#######.#.###.###.###.###.###.###.#.#.#####.#.#.#.#.#######.###.###.###.#.#.#.###.#.#.###.###.# +#.#.......#.#.......#.#...#.......#...#.#.........#...#...#...........#...#.......#.#...#.......#.........#.......#...#...#.....#.......#...# +#.#.#.###.#.#######.#######.#####.###.#.#.#.#####.#.#####.#.#########.###.#########.#.#.#.###########.#.###.###.#.#.###.#########.#######.#.# +#...#.#...#.#.....#.#.......#.........#.#.#.....#...#.....#...#.....#...#.#...#.....#.#.#...#.......#...#...#...#.....#.....#.......#.....#.# +#####.#.###.#####.#.#.###.###.#######.#.#.#####.#.###.#######.#.###.#.#.#.#.###.#.###.#.###.#######.#####.###.###.###.#####.#####.#.#.#####.# +#.....#...#.....#.#...#...#...#.......#.#.#.....#.#...#...#...#.#...#.#.....#...#.....#...#.......#.....#...#.#.....#...#.#.........#.....#.# +#.#.#######.###.#.#####.###.#.#.#######.#.###.#####.###.#.#####.#.###.#.#####.###.#######.#######.#.#.###.#.#.#########.#.#####.#.#######.#.# +#.#.#...........#...#...#...#...#.....#.#...#.......#...#.......#...#.....#...#.#...#...........#.#.#...........#.....#.#.#.....#.........#.# +#.#.#.#####.#######.#.#####.#####.###.#.###.#####.###.###########.#.#######.###.#.#.###.#####.###.#.###.#.#.###.#.###.#.#.#.###.#.#########.# +#.#.#...............#.....#.#.....#...#...#...#...#...#...#.....#.#...........#.#.#.....#.....#...#.#.#.....#...#...#.....#.#.....#.....#...# +#.#.#.#.#.#.#######.#####.#.#.#####.#####.###.#####.#####.#.###.#.#######.###.#.#.#####.#.#####.###.#.#######.#.###.#.#.#.#.#.#.#.###.###.### +#.#.#.#.#.#.......#.....#.#.#.....#.......#.#.....#...#...#...#.#.......#.#...#...#.....#.....#.#...#.......#.#...#.#.#.#...#.#.....#.......# +#.###.#.###.#####.#######.###.#.###########.#.#.#.###.#.#####.#.###.#####.#.###.###.###.#######.#.#.#####.#.#.#####.#.#.#####.#.###.#######.# +#.....#...#.....#...#...#...#.#.#.....#.....#...#...#.#.#.....#...#.#.....#.#.....#.#...#.....#.#...#...#.#.#.......#.........#...#.......#.# +#.#######.#.###.###.#.#.###.#.#.#.#.###.#.#.#####.###.#.#.#######.#.#.###.#.#####.#.###.#.###.#.#.###.#.#.#.#######.#########.#.#.#######.### +#.....#...#.....#.#...#...#.#.#.#.#.....#.#...#...#...#.#.....#.#.#.#...#.#...#...#...#.#.#...#.#.#...#.#.#...#...#.#.....#.............#...# +#####.#.#.#.#####.#######.#.#.#.#.#######.###.#.###.###.#####.#.#.###.#.#####.#######.###.#.###.#.#.###.#.###.#.#.###.###.#.###.###.#######.# +#.#...#.#.#.#...#...........#.#...#...#.#...#.#...#...#...#.#...#...#.#.#...#.#.....#.#...#.....#...#.....#...#.#.....#.#.#.......#.#.....#.# +#.#.###.#.#.###.#.###########.#.###.#.#.###.#.###.###.#.#.#.#.#.###.###.#.#.#.#.###.#.#.#############.#########.#######.#.###.#.###.#.###.#.# +#...#...#.#.#...#.#...........#.....#.#.#...#...#...#...#.#.#.#...#.#...#.#.....#.....#.#...#.........#.........#.......#...#.#.....#.#...#.# +#.###.#.###.#.###.#.#######.#.#######.#.#.#####.###.#####.#.#.#.###.#.#.#.#######.###.#.#.#.#####.#####.#########.#####.###.#.#.#####.#.###.# +#...#.#...#.#.....#.#.....#...#...#...#.#.#.#.....#...#...#.#.#...#.#.#.#...#.......#.#...#.....#...#...#.....#...#...#...#.....#.....#.#...# +###.#.###.#.#######.#.#########.#.###.#.#.#.#.###.#.###.###.#.#.#.#.#.#.###.#.#####.#####.#####.#.#.#.#####.#.#.#.#.#.###.###.#.#.#####.###.# +#...#.#...#.........#...........#...#...#.#.......#.....#...#.#.#.....#.#...#.....#.#...#.#.........#.#.....#.#.#...#.....#...#.#.#...#.....# +#.#.#.#.#########.#######.#########.###.#.#.#####.#######.###.###########.#######.#.#.#.###.#####.#.#.#.#####.#.#.#.#######.#.#.#.#.#.#####.# +#.#...#.#...............#.....#...#.#.#.#.#...#.#...#.......#...#.........#.#...#.#...#.....#...#...#.#.#...#.#.#.#...#.#...#.#.#...#.#.#...# +#.#.###.#.#######.#####.#.###.#.#.#.#.#.#.#.#.#.###.###.###.###.#.#########.#.#.#.#####.#####.#.#####.#.#.#.#.###.###.#.#.#####.###.#.#.#.### +#.#...#...#.......#...#.#.#...#.#.#.#...#.#.#.....#...#.#...#...#...#.#.......#.#...#...#.....#.........#.#.#.....#.......#...#.#.........#.# +#.#.#######.#########.#.#.#.#####.#.###.#.#.#####.###.#.#.#.#.#.###.#.#.#######.###.#####.#########.#####.#.#######.#####.#.#.#.#.#.###.###.# +#.#.#.....#.....#.....#.#.#.....#.#...#.#.#.....#.#...#...#.#.#.#...#.....#.....#...#...#.#...#.....#.....#...#.....#...#...#...#.....#.#...# +#.#.#.#.#.#####.#.#####.#.#####.#.#.#.#.#.#.###.###.#######.#.#.#.###.###.#.###.#.#.#.#.#.#.#.#.###.#######.#.#.#####.#.###########.#.#.#.#.# +#.#.#.#.................#.....#.#.#...#.#.#...#.....#.......#.#.#.#.....#.#.#...#.#.#.#...#.#.#.............#.#.#...#.#.........#.....#.#.#.# +#.#.#.#.#########.###.###.#####.#.#.#####.#.#####.###.#.#.###.###.#.#.#.###.#.###.###.#####.#.#.#.#############.###.#.#######.#.#.#.###.#.#.# +#.#.#.....#.....#.#.......#.....#.#.#.....#.#...#.....#...#...#...#.#.#.#...#...#.....#.....#.#...#...........#.#...#.#.....#.............#.# +#.#.###.#.###.###.###.#.###.#####.#.#.#######.#.#######.###.#.#.#####.#.#.#####.###########.#.#.###.#########.#.#.###.#.#.#.#.###.#.#.###.#.# +#.#.....#.......#...#...#.#.#.....#.#.#...#...#.......#...#.#.........#.#...#.#...#.........#.#.........#...#.#.#...#.#.#.#.#...#.#.#...#.#.# +#.#.###.###.###.#.#.###.#.#.###.#.#.#.#.#.#.#######.#.###.#.###.###.###.###.#.#.#.###.#######.#######.###.#.#.#.###.#.#.#.#.###.#.#.#.###.#.# +#.#...#.....#...#.#...#...#.#...#.#.#...#.#.......#.....#.#.#...#...#.#.........#...#.#.......#.....#.#...#.#.....#.#...#.#...#...#.#.....#.# +#.#.#.#.#####.#.#.###.#####.#.#####.#.###.#######.#.#.###.#.#.###.###.#########.###.#.#.#######.###.#.#.###.#####.#.#####.#.#######.#.#####.# +#.#.#.#.#.....#.....#.......#.#.....#...#...#...#.#.#.....#.#.#...#.....#.........#...#...#.....#.#.#...#.#...#.......#...#.................# +#.#.#.#.#####.###############.#.#######.#.#.###.#.#.###.###.#.#.#######.#.#.###########.###.#####.#.###.#.###.#########.#############.####### +#...#.#.....#...#.......#...#...#.......#.#...#.#.#...#.#.....#.#.......#.#.#.......#...#...#.....#...#.#...#.................#.....#.......# +###.#.#.###.#.#.#.#.###.###.#.#######.###.###.#.#.###.###.###.#.###.#.###.#.#.#.#.#.#.###.###.#######.#.#.#.#########.###.###.#.###.#.#####.# +#...#.#.#.#.#.#...#...#.....#.#.....#.#...#.#.#.#.#.#...#.#...#...#.......#...#...#.#.#.#.#.........#.#.#.#.#.......#.....#.#...#.#.#...#.#.# +#.#.#.#.#.#.#########.#####.#.#.###.###.###.#.#.#.#.###.#.#.#####.#.###########.###.#.#.#.###.#.#.#.#.#.###.#.#.###.###.#.#.#####.#.#.#.#.#.# +#.#.#.#...#.#.......#...#...#...#.#...#.#.......#...#.#.#...#.....#.#...#.....#.....#.#.#...#.#...#...#...#.#.#.#.#.#.#.#.#.......#.........# +#.###.###.#.#.#####.#.#.#.#######.#.#.#.###########.#.#.#####.#####.###.#.#.#####.###.#.###.###.#######.#.#.#.#.#.#.#.#.#.###.###.###.#.###.# +#.............#.#...#.#.#.#...#.....#.#...........#.#.#...........#...#...#.#...#.......#.#...#.........#.#...#.#.....#.#.#.................# +#.#####.#.###.#.#.###.#.#.#.#.#.###.#.###.#####.###.#.#########.#.###.#####.#.#.#######.#.###.###.#####.#.#.###.#######.#.#.###.###.#####.#.# +#.#.....#.....#...#...#.#.#.#.#...#.#...#.#...#.#...#.....#.......#.#...#...#.#...#...#.....#.#.......#.#.#...#.....#...#.#.#...#.......#.#.# +#.#.#####.#.###.#######.#.#.#####.#.###.#.#.#.#.#.###.#####.#######.###.#.###.###.#.#.#######.#######.###.###.#####.#.###.#.#.#####.###.#.#.# +#.............#.#...#.....#.....#.#.....#.#.#.#.#.#...#.....#.............#...#.#...#...#...#.......#...#.#...#...#.#.#.#...#.....#...#.#.#.# +###.#.###.###.#.#.#.#.###.#.#.#.#.#######.#.#.#.#.#.#.#.#####.#############.###.#######.#.#.#######.###.#.#.###.###.#.#.#########.#.###.#.### +#...#...#...#.....#.#...#.#.#.#...#.....#...#.#.....#.#...#.#.#...#.....#...#.......#.#...#.#.......#.....#...#...#...#.....#...#.#.....#...# +#.###.#.#.###.#####.###.#.###.#.#.#.###.#####.###########.#.#.#.###.#####.#.#.###.#.#.#####.#.#######.#######.###.#######.###.#.#.#.#######.# +#...#.#...#...#...#.#...#...#.#.#.#.#.#...#.#.#.....#.....#.#.#.#...#.....#.....#.#...#...#.#.#.....#.........#...........#...#...#.....#...# +###.#.###.#.#####.#.#.#####.#.###.#.#.###.#.#.#.###.#.#####.#.#.#.###.###.#######.###.#.#.#.#.#.###.#.###.#.#.#.#######.###.#######.###.#.### +#...#...#.#.#...#.#.#.#.#...#...#...#.....#...#.#.#...#.#...#...#.#.#.#.#...#.....#.#.#.#.#.#.#.#...#.#...#.#.#.#.......#...#.#.........#...# +#.#####.#.#.#.#.#.#.#.#.#.#####.#####.#####.###.#.#####.#.#.#.###.#.#.#.###.#.#####.#.#.#.#.#.#.###.#.#.###.#.#.#########.###.#.#.#.###.###.# +#.#.......#.#.#...#.#.#.#.#.....#...#.....#...#.#.........#...#...#.......#.#...#.......#.#...#.......#...#.#.#...........#...#.#.#...#.#...# +#.#.#####.#.#.#####.#.#.#.###.#.#.#######.###.#.#.#####.#######.#.#######.#.###.###############.#########.#.#.###.###########.#.#.#.#.#.#.#.# +#.#.#.......#...#...#.#.#.#...#...#...#...#...#.#.......#...#.#.#...#.....#.#...#...............#.#...#...#.#...#.#.........#...#.#.#...#...# +#.#.#.#######.#.#.###.#.#.#.###.###.#.#.#######.#.#######.#.#.#.#.#.###.###.#.###.#########.#####.#.#.#.#######.#.#.#.#####.#.###.#.#######.# +#.#.#...#.....#.......#...#...#.#...#...#.......#.........#...#...#...#.#...#...............#.....#.#...#...#.......#.#...#.#.#...#...#...#.# +#.#.###.#################.###.#.#.#######.#.#######.#################.#.#.###.#######.#####.#.###.#.#####.#.#.#########.#.#.###.###.###.#.#.# +#.#.#.#.....#.....#.....#.....#.#.....#.#.#.#.#.....#...#.........#...#.#.#...#...#.#.....#.#...#.#.......#.#.....#.....#.#.#...#...#...#...# +#.#.#.#####.#.###.#.###.#####.#######.#.#.#.#.#.#####.#.#.#######.#.###.#.#####.#.#.#.###.#.#.#.###########.#####.#.#####.#.#.###.###.#####.# +#.....#...#.......#...#.......#.......#...#.#.....#...#...#.......#.#...#.#.....#.#.#...#.#.#.#.......#...#...#.#...#...#.#...#.....#...#...# +#.#####.#.#######.#.###.#######.###########.#.#####.#######.#####.#.#####.#.#####.#.#.###.#.#.#######.#.#.#.#.#.#####.#.#.#########.###.#.#.# +#...#...#...#.....#.#...#.....#.....#.......#.#.#...#...#...#.....#.......#...#.#.#...#...#.#...#.....#.#...#...#.....#.#.....#.......#.....# +#####.#.###.#.#.###.#.#.#.###.#####.#.#######.#.#.#####.#.###.#############.#.#.#.#.###.#.#.###.#.#.#.#.#######.#.#####.#.###.#.###.#.#.#.#.# +#...#.#.....#.#.#...#.#.#.#.#.#.....#...........#.#.....#.#.#.#.............#.#.#.#...#.#.#.#...#.#.#.#.......#.#.#.........#.#.#.......#...# +#.#.#.#.#####.###.###.#.#.#.#.#.#####.###.###.#.#.#.###.#.#.#.###.#######.###.#.#.#####.#.#.###.#.#.#.#.#.#.#.#.###.#######.#.#.###.#######.# +#.#...#.......#...#...#.#...#.#.....#.#.#.....#...#...#...#.#...#.#...#.......#...#.....#.#...#.#.#.....#...#.#.....#.....#.#.#.........#...# +#.#####.#.###.#.###.#.#####.#.#####.#.#.#####.###.###.###.#.###.#.#.#.#.#######.###.#########.###.#####.#####.###########.#.#.#####.###.#.#.# +#.#...#.....#.#...#.#.#...#.#.....#.#.#.....#.#...#...#...#.#...#.#.#.#.......#.#...#.......#.#...#.#...#...#.#.........#...#.........#.#...# +#.#.#.#.#.###.###.#.#.#.#.#.#.###.#.#.#.###.#.#.###.###.###.#.#####.#.#.#.#.#.#.#.#.#.###.#.#.#.###.#.#.###.#.#.#######.#.#########.#.#.#.#.# +#.#.#...#.#.....#.#.....#...#...#.#.#...#...#...#...#...#...#.......#...#.#...#.#.#.#.#...#.#.#...#...#.....#.....#.....#...#.......#...#.#.# +#.#.###.#.#.#####.#############.#.#.#######.#####.#.#.###.#############.#.#.###.#.#.#.#.#.###.###.#.###.#.#.#######.#######.###.#.#.#######.# +#.#.#...#...#.....#.....#.....#.#.#...#...#.......#.#...#...#.........#...#.....#.#.#...#...#.....#.#...#.#.#.......#.....#...#.#.........#.# +#.#.#.###.###.#####.###.###.#.#.#####.#.#.#########.###.###.#.#####.#.#####.#####.#.#.#.###.#######.#####.#.#.#.#####.#######.###.#.###.#.#.# +#.#.#.#.#.#.#.#.......#.....#.#.....#...#.#.......#...#...#.#...#...#...#...#.....#.#...#.#...#...#.#...#.#.#.#.#...........#...#.#.....#...# +#.#.#.#.#.#.#.#.#####.###.#########.#####.#.###.###.#####.#.#.#.#.#######.###.#####.###.#.###.#.#.#.#.#.#.#.#.#.#.#######.#####.#.#.#######.# +#.#.........#.#.....#.#...#.......#.#.....#...#.....#.....#.....#.....#...#...#...#...#...#.#...#.#...#.#.#...#.#.....#...#.....#.#...#.#...# +#.#.#.###.#.#.###.###.#.###.###.###.#.#####.#########.#.#####.#######.#.###.###.#.#.#####.#.#####.#####.#.###.#.#####.#.###.#####.###.#.#.### +#...#.................#.#...#...#...#.....#.#.......#.#.#...#.....#...#.#.....#.#.#.....#.#.......#...#...#...#.#.....#.#...#...#.#.#.#.....# +#.#####.#####.#.###.#####.###.###.#.#####.###.#####.#.###.#.#####.#.#.#.#####.#.#######.#.###.#.#.#.#.#.#######.#######.#.###.#.#.#.#.####### +#...#.#.#...#.#...#.........#.....#.....#...#...#...#.....#...#.....#.#...#...#.......#.#.#...#.#...#...#.......#.......#.#...#.#...#.#.....# +###.#.#.#.#.#.###.###########.#.#####.#####.###.#.###########.#.#.#######.#.###.#.###.#.#.#.#.#########.#.#######.#####.#.###.#.#####.#.###.# +#...#.#...#.#...#.#.........#.#.#...#.#.....#...#.......#...#.#...#...#.........#...#.#...#.#.#...#...#.#.#...#.....#...#.....#...#...#...#.# +#.###.#####.###.###.###.#.#.#.#.#.#.#.#.#####.#########.#.#.#.#.###.#.#.#######.###.#######.###.#.#.#.#.#.#.#.#.###.#############.#.###.###.# +#.#...#.....#...#...#...#.#...#.#.#...#.......#.....#...#.#...#...#.#...#.....#...#.#.....#.....#.#.#...#.#.#.#.#...#.....#.....#.#.....#...# +#.###.#.###.#.###.#####.#.###.#.###############.###.#.###.#####.#.#.#######.#####.#.#.#.#.#######.#.###.#.#.###.#.###.###.#.###.#.#####.#.### +#.....#.#...#...#.#...#.#...#.#.#...........#.....#.#.#...#.....#...#.......#...#.....#.#.....#...#...#.#.#.#...#.....#.#.#.#.#.#.....#.#...# +#.#.#.#.###.###.#.#.#.#.###.###.#.###.###.#.#######.#.###.#.###.#####.###.###.#.#.#####.#####.#.#.###.#.#.#.#.#########.#.#.#.#.#####.###.#.# +#...#.#...#.....#.#.#.#.....#...#.......#.#.........#...#.#...#...#.....#.....#.....#...#.#.....#.#...#...#.#.....#.....#...#.#.....#...#.#.# +#####.###.#.#.###.#.#.#######.#########.#.#######.#####.#.###.#.#.#######.#######.#.#.###.#.#.#.#.#.#######.#####.#.###.#####.#.###.###.###.# +#.#.....#.#.#...#.#.#.........#.......#.#.#.....#.#...#.#...#...#.#.....#.#.......#...#.#.......#.#.#...#.......#...#...#.....#...#...#...#.# +#.#.#.###.#.###.#.#.###.#####.#.#.#####.#.#.###.###.#.#.#.#.#####.#.###.###.#####.###.#.#.#########.#.#.#.###.#######.#.#.###.###.#######.#.# +#...#.....#...#...#.....#...#.#.#.......#.#...#.#...#.....#.#.....#...#.....#...#.#.......#...#.....#.#.#...#.......#...#.#.#...#...#...#.#.# +#.###.###########.###.#.#.#.#.#.#########.###.#.#.#.#######.#.#######.#######.#.#.#########.#.#.#####.#.###.#.###.#.###.#.#.###.###.#.#.#.#.# +#.#.#.....#.......#.#.#.#.#.#.#.......#.....#.#...#...#.....#.#.....#.....#...#.#...........#.#...#...#...#.#...#.#.#...#.#.#...#.#...#.#...# +#.#.#####.#.#####.#.#.###.#.#######.#.#.#####.#####.#.###.###.#.###.###.#.#.###.#############.###.#######.#.#.#.#.#.#.###.#.#.###.#####.###.# +#...#...#.#...#.....#.....#.......#.........#.#.....#.#...#.#.#...#...#.#.....#.......#.....#...#...........#.#...#.#.#...#.#.#.......#.....# +###.#.#.#.###.#.###.#############.#.#######.#.#####.#.#.###.#.###.###.#.#########.###.#.#.#####.#.#####.#.###.#####.#.#.###.#.#.###.######### +#...#.#.#.#...#.#...#...........#.#.....#.......#...#...#...#...#.#.#.#...#.#.........#.#.......#...#...#.#.#.....#...#...#...#.#...#.....#.# +#####.#.#.#.###.#.###.###.#####.#.#####.#.#####.#.#.#####.#####.#.#.#.###.#.#.###########.###########.###.#.#####.#.#####.###.###.###.#.#.#.# +#...#.....#.#...#.....#...#...#.#.....#.#.#.....#.#.....#.....#...#...#.#.#.#...........#.................#...#...#.....#...#...#.....#.#.#.# +#.#.#.###.#.#.#.#######.###.#.#######.#.#.#.#####.#.#.#.#.###.#####.###.#.#.#########.#.#######.#.#####.#.###.#.#.#####.#.#.###.#######.#.#.# +#.#...#.....#.#.....#...#...#.........#.#...#.....#...#...#...........................#...#...#.#.#...#.....#.#.....#...#.#...#.....#...#.#.# +#.###.#.#.###.#.###.#.###.#.#########.#.#.###.#####.#####.#.#.#.###.#.#.###.#.#######.###.#.###.#.#.#.###.#.#.#.###.#.#.#.###.#####.#.###.#.# +#...#.#.....#.#...#.#.#...#.#...#...#.#...#.......#...#.#...#.#.#...#.#...#.#.....#...#...#.....#...#...#.....#.#...#.#.....#.....#.#.#.....# +#.#.#.###.#.#.#.#.#.###.###.#.#.#.#.#.###.#######.#.#.#.#.#.#.#.#.#######.#.#####.#.#.#.###.#####.#####.#.#####.#.#.#.#.#######.#.#.#.#.###.# +#.#.#.....#.#...#.#.....#.#.#.#...#.#...#...#.....#...#...#...#.#.......#.......#.#.#...#...#.........#.....#...#.#...#.#.....#.#.#.#.....#.# +#.#.#####.#.#.#.#.#######.#.#.#####.#####.#.#.#####.###.#.#.###.#######.#.#.#####.#.#.###.###########.#####.#.#.###.#.#.#.###.###.#.###.#.#.# +#.#.#...#.#.#.#.#...#.......#.....#.......#.#.#.....#...#.#.......#...#...#.#...........................#...#.#.....#...#...#.#...#.......#.# +###.#.#.#.#.#.#.###.###########.#.#####.#.#.#.#.#.#.###.#.#.#####.#.#.###.###.#####.###.#.#.###.#.#.###.#.###.#.###.#.#####.#.#.#######.###.# +#...#.#.....#.#...#.#...........#.#...#.....#.#.#.#...#.........................#.#.#...#...#...#.#.....#.#.....#...........#.#...#.#...#...# +#.#.#.###.#####.#.#.#.#######.###.#.#########.#.###.#.###.#.#####.#.#.###.#.#.#.#.#.#.#######.#########.#.###.###.#.#.#######.###.#.#.#.#.### +#.#.#.#...#.....#.#.#.#.....#.#...#...........#...#.........................#.#.#...#.#.#...#.#.............#...#.......#...#.....#...#.....# +#.###.#.#.#.#####.#.#.#####.#.#.###########.###.#.#.###.#.#.###.###.#.#.#.#.###.#.###.#.#.#.#.#.#.#.#.#####.###.###.#.#.#.#.#######.###.#.#.# +#S......#...#.....#.........#...............#...#.....#.......#.....#...#.......#.....#...#.....#...#.......#...........#.#.................# +############################################################################################################################################# diff --git a/2024/day16/input.txt.h b/2024/day16/input.txt.h new file mode 100644 index 0000000..42c8bc8 --- /dev/null +++ b/2024/day16/input.txt.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_2024_day16_input_txt_start __asm("_binary_2024_day16_input_txt_start"); +extern uint32_t _binary_2024_day16_input_txt_end __asm("_binary_2024_day16_input_txt_end"); +extern uint32_t _binary_2024_day16_input_txt_size __asm("_binary_2024_day16_input_txt_size"); + +#ifdef __cplusplus +} +#endif diff --git a/2024/day16/sample1.txt b/2024/day16/sample1.txt new file mode 100644 index 0000000..2c21676 --- /dev/null +++ b/2024/day16/sample1.txt @@ -0,0 +1,15 @@ +############### +#.......#....E# +#.#.###.#.###.# +#.....#.#...#.# +#.###.#####.#.# +#.#.#.......#.# +#.#.#####.###.# +#...........#.# +###.#.#####.#.# +#...#.....#.#.# +#.#.#.###.#.#.# +#.....#...#.#.# +#.###.#.#.#.#.# +#S..#.....#...# +############### diff --git a/2024/day16/sample1.txt.h b/2024/day16/sample1.txt.h new file mode 100644 index 0000000..94918e8 --- /dev/null +++ b/2024/day16/sample1.txt.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t _binary_2024_day16_sample1_txt_start __asm("_binary_2024_day16_sample1_txt_start"); +extern uint32_t _binary_2024_day16_sample1_txt_end __asm("_binary_2024_day16_sample1_txt_end"); +extern uint32_t _binary_2024_day16_sample1_txt_size __asm("_binary_2024_day16_sample1_txt_size"); + +#ifdef __cplusplus +} +#endif diff --git a/2024/day16/solution.c b/2024/day16/solution.c new file mode 100644 index 0000000..2f04949 --- /dev/null +++ b/2024/day16/solution.c @@ -0,0 +1,11 @@ +#include + +int64_t _2024_day16_part1(const char * input, int length) +{ + return -1; +} + +int64_t _2024_day16_part2(const char * input, int length) +{ + return -1; +} diff --git a/dijkstra.c b/dijkstra.c new file mode 100644 index 0000000..40be6d2 --- /dev/null +++ b/dijkstra.c @@ -0,0 +1,32 @@ +#include "cartesian.h" +#include "dijkstra.h" +#include "heap.h" +#include "memory.h" + +void dijkstra_cartesian(char * graph, + int stride, + int width, int height, + int source_x, int source_y, + int dest_x, int dest_y, + char wall) +{ + struct heap_entry queue[width * height / 2 + 1]; + int queue_length = 0; + + // distance from source + int dist[width * height]; + // initialize all distances to the maximum distance + memory_set_int(dist, 0x7fffffff, width * height); + // initialize the distance from the source to the source to zero + dist[source_y * width + source_x] = 0; + + + int prev[width * height]; + // initialize the all node paths to "unknown" + memory_set_int(prev, -1, width * height); + + // initialize the queue with "source" + heap_append_xy(queue, &queue_length, 0, source_x, source_y); + + //while queue_length > 0: +} diff --git a/dijkstra.h b/dijkstra.h new file mode 100644 index 0000000..e69de29 diff --git a/heap.c b/heap.c index f1214a7..d5c6d2e 100644 --- a/heap.c +++ b/heap.c @@ -1,4 +1,5 @@ #include "heap.h" +#include "memory.h" void heap_sift_up(struct heap_entry * e, int ix) { @@ -16,6 +17,31 @@ void heap_sift_up(struct heap_entry * e, int ix) } } +void heap_sift_down(struct heap_entry * e, int heap_length, int ix) +{ + while (true) { + int child_l = 2 * ix + 1; + int child_r = 2 * ix + 2; + if (child_l >= heap_length) + break; + + int child = child_l; + if (child_r < heap_length && e[child_l].key < e[child_r].key) { + child = child_r; + } + + if (e[ix].key < e[child].key) { + // swap child and ix + struct heap_entry tmp = e[child]; + e[child] = e[ix]; + e[ix] = tmp; + ix = child; + } else { + break; + } + } +} + void heap_append(struct heap_entry * e, int * heap_length, int key, int value) { int ix = *heap_length; @@ -25,6 +51,16 @@ void heap_append(struct heap_entry * e, int * heap_length, int key, int value) (*heap_length) += 1; } +void heap_append_xy(struct heap_entry * e, int * heap_length, int key, int x, int y) +{ + int ix = *heap_length; + e[ix].key = key; + e[ix].x = x; + e[ix].y = y; + heap_sift_up(e, ix); + (*heap_length) += 1; +} + int heap_find(struct heap_entry * e, int length, int ix, int key) { if (e[ix].key == key) @@ -47,3 +83,14 @@ int heap_find(struct heap_entry * e, int length, int ix, int key) return -1; } + +struct heap_entry heap_extract_max(struct heap_entry * e, int * heap_length) +{ + struct heap_entry entry = e[0]; + + (*heap_length)--; + memory_copy_u32(&e[1], *heap_length, &e[0]); + heap_sift_down(e, *heap_length, 0); + + return entry; +} diff --git a/heap.h b/heap.h index 21fb15a..9a22772 100644 --- a/heap.h +++ b/heap.h @@ -1,17 +1,28 @@ #pragma once +#include + #ifdef __cplusplus extern "C" { #endif struct heap_entry { int key; - int value; + union { + int value; + struct { + int16_t x; + int16_t y; + }; + }; }; void heap_sift_up(struct heap_entry * e, int ix); +void heap_sift_down(struct heap_entry * e, int heap_length, int ix); void heap_append(struct heap_entry * e, int * heap_length, int key, int value); +void heap_append_xy(struct heap_entry * e, int * heap_length, int key, int x, int y); int heap_find(struct heap_entry * e, int length, int ix, int key); +struct heap_entry heap_extract_max(struct heap_entry * e, int * heap_length); #ifdef __cplusplus } diff --git a/input_dreamcast.inc b/input_dreamcast.inc index 17b93d4..509e45f 100644 --- a/input_dreamcast.inc +++ b/input_dreamcast.inc @@ -41,6 +41,8 @@ #include "2024/day14/input.txt.h" #include "2024/day15/sample1.txt.h" #include "2024/day15/input.txt.h" +#include "2024/day16/sample1.txt.h" +#include "2024/day16/input.txt.h" static struct start_size sample[][2] = { { @@ -163,6 +165,12 @@ static struct start_size sample[][2] = { { ( char *)&_binary_2024_day15_sample1_txt_start, (uint32_t)&_binary_2024_day15_sample1_txt_size }, }, + { + { ( char *)&_binary_2024_day16_sample1_txt_start, + (uint32_t)&_binary_2024_day16_sample1_txt_size }, + { ( char *)&_binary_2024_day16_sample1_txt_start, + (uint32_t)&_binary_2024_day16_sample1_txt_size }, + }, }; static struct start_size input[] = { @@ -206,4 +214,6 @@ static struct start_size input[] = { (uint32_t)&_binary_2024_day14_input_txt_size }, { ( char *)&_binary_2024_day15_input_txt_start, (uint32_t)&_binary_2024_day15_input_txt_size }, + { ( char *)&_binary_2024_day16_input_txt_start, + (uint32_t)&_binary_2024_day16_input_txt_size }, }; diff --git a/linear_algebra.c b/linear_algebra.c index dd9d258..27251f3 100644 --- a/linear_algebra.c +++ b/linear_algebra.c @@ -1,7 +1,6 @@ #include "linear_algebra.h" #include "printf.h" -//#include double determinant_2x2(double a, double b, double c, double d) @@ -14,32 +13,6 @@ double determinant_2x2(double a, double b, return a * d - b * c; } -/* -5550.00 450000000444000.00 600000000222000.00 -81081081161.08 108108108148.11 - --3876.00 -460000000548084.00 -400000000524792.00 -118679050709.00 103199174542.00 - --6595.00 -470000000250610.00 -690000000567170.00 -71266110727.92 104624715779.71 - -4278.00 440000001045978.00 460000000280508.00 -102851800151.00 107526881786.00 -*/ - -union di { - double d; - int64_t i; -}; - -static int64_t raw_double(double n) -{ - union di di; - di.d = n; - return di.i; -} - struct double2 cramers_rule_2x2(double a1, double b1, double c1, double a2, double b2, double c2) { diff --git a/memory.c b/memory.c index fc68db0..ed5f3d3 100644 --- a/memory.c +++ b/memory.c @@ -22,3 +22,14 @@ void memory_copy_char(char * src, int length, char * dst) dst[i] = src[i]; } } + +void memory_copy_u32(void * _src, int length, void * _dst) +{ + // size given in bytes + uint32_t * src = _src; + uint32_t * dst = _dst; + + for (int i = 0; i < length; i++) { + dst[i] = src[i]; + } +} diff --git a/memory.h b/memory.h index f8c7995..78f9430 100644 --- a/memory.h +++ b/memory.h @@ -7,6 +7,7 @@ extern "C" { void memory_set_char(char * buf, char c, int length); void memory_set_int(int * buf, int c, int length); void memory_copy_char(char * src, int length, char * dst); +void memory_copy_u32(void * _src, int length, void * _dst); #ifdef __cplusplus } diff --git a/runner.inc b/runner.inc index a731291..3b5efcb 100644 --- a/runner.inc +++ b/runner.inc @@ -44,6 +44,8 @@ void _2024_day14_render(const struct font * font, const void * maple_ft0_data); int64_t _2024_day15_part1(const char * input, int length); int64_t _2024_day15_part2(const char * input, int length); +int64_t _2024_day16_part1(const char * input, int length); +int64_t _2024_day16_part2(const char * input, int length); struct day_funcs solution[] = { { @@ -146,4 +148,9 @@ struct day_funcs solution[] = { {_2024_day15_part1, _2024_day15_part2}, NULL, }, + { + 2024, 16, + {_2024_day16_part1, _2024_day16_part2}, + NULL, + }, }; diff --git a/solutions.mk b/solutions.mk index 9217c94..8aac665 100644 --- a/solutions.mk +++ b/solutions.mk @@ -63,4 +63,7 @@ DAY_OBJ = \ 2024/day14/solution.o \ 2024/day15/sample1.txt.o \ 2024/day15/input.txt.o \ - 2024/day15/solution.o + 2024/day15/solution.o \ + 2024/day16/sample1.txt.o \ + 2024/day16/input.txt.o \ + 2024/day16/solution.o diff --git a/test/run.sh b/test/run.sh new file mode 100644 index 0000000..15e34cf --- /dev/null +++ b/test/run.sh @@ -0,0 +1,19 @@ +#!bin/bash + +set -eux + +for i in test/test_*.c; do + name=${i%.c} + gcc -Og -g -gdwarf-5 \ + -std=c2x \ + -Wall -Werror -Wfatal-errors \ + -Wno-error=unused-variable \ + -I. \ + -o ${name} \ + ${name}.c \ + memory.c \ + dijkstra.c \ + heap.c + + ./${name} +done diff --git a/test/runner.h b/test/runner.h new file mode 100644 index 0000000..88630b1 --- /dev/null +++ b/test/runner.h @@ -0,0 +1,27 @@ +#pragma once + +typedef bool (*test_t)(const char ** scenario); + +#define ANSI_RED "\x1b[31m" +#define ANSI_GREEN "\x1b[32m" +#define ANSI_RESET "\x1b[0m" + +#define RUNNER(tests) \ + int main() \ + { \ + int fail_count = 0; \ + for (int i = 0; i < (sizeof (tests)) / (sizeof (test_t)); i++) { \ + const char * scenario = NULL; \ + bool result = tests[i](&scenario); \ + const char * result_s = result ? "ok" : ANSI_RED "fail" ANSI_RESET; \ + fail_count += !result; \ + fprintf(stderr, "%s: %s\n", scenario, result_s); \ + } \ + if (fail_count == 0) { \ + fprintf(stderr, ANSI_GREEN "failed tests: %d\n\n" ANSI_RESET, fail_count); \ + } else { \ + fprintf(stderr, ANSI_RED "failed tests: %d\n\n" ANSI_RESET, fail_count); \ + } \ + \ + return !(fail_count == 0); \ + } diff --git a/test/test_heap.c b/test/test_heap.c new file mode 100644 index 0000000..0c27387 --- /dev/null +++ b/test/test_heap.c @@ -0,0 +1,21 @@ +#include +#include + +#include "runner.h" + +#include "heap.h" + +static bool heap_test_0(const char ** scenario) +{ + *scenario = "heap_extract_max"; + + + + return false; +} + +test_t heap_tests[] = { + heap_test_0, +}; + +RUNNER(heap_tests) diff --git a/test/test_memory b/test/test_memory new file mode 100755 index 0000000..1fbe435 Binary files /dev/null and b/test/test_memory differ diff --git a/test/test_memory.c b/test/test_memory.c new file mode 100644 index 0000000..8eb94cb --- /dev/null +++ b/test/test_memory.c @@ -0,0 +1,23 @@ +#include +#include + +#include "runner.h" + +#include "memory.h" + +static bool memory_test_0(const char ** scenario) +{ + *scenario = "memory_copy_u32 ordering"; + + uint32_t l[] = {1, 2, 3, 4}; + + memory_copy_u32(&l[1], 3, &l[0]); + + return l[0] == 2 && l[1] == 3 && l[2] == 4; +} + +test_t memory_tests[] = { + memory_test_0, +}; + +RUNNER(memory_tests)