aoc2024

Advent of Code 2024
Log | Files | Refs | README

commit ad6ecfd9a59991729b79987f0ec8711e0589eb5e
parent b4586e83a0e12f8a320c8625eff2288860a36618
Author: Martin Ashby <martin@ashbysoft.com>
Date:   Sat,  4 Jan 2025 22:25:43 +0000

Day 16 pt1

Diffstat:
Aday16.txt | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aday16_sample.txt | 17+++++++++++++++++
Asrc/main/java/day16_pt1.java | 153+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 311 insertions(+), 0 deletions(-)

diff --git a/day16.txt b/day16.txt @@ -0,0 +1,141 @@ +############################################################################################################################################# +#.........#...........#.................#.......#.............#.....#.#...#...........#.....#.....#...#.......#.....#...........#.......#..E# +#.#######.#.#.#######.###.#########.###.#######.#.#.#.###.#.#.###.#.#.#.#.#.#####.#.###.#.#.#.#.#.#.#.#.#.#.#.#.###.#.#####.###.#.#####.###.# +#.#.....#.#.#.#.....#...............#.#.#.....#...#...#.#.#.......#...#.#.#.....#.#.#...#.....#.#.#.#...#.#.....#.#.........................# +#.#.###.#.#.#.###.#######.###########.#.#.###.#.#######.#.#.#########.#.#.#.#####.###.#####.###.#.#.#####.#######.#.#.#.#.#.#.#.###.#.#.#.### +#...#.#.#...#...#...#.....#...........#.#...#.#.#.......#.#.........#.#.#.#.#.....#...#.........#.#.....#.......#.#.#.#.....#.......#...#...# +#.#.#.#.#######.###.#.###.#.#########.#.###.#.#.#####.#.#.#.###.###.###.#.#.#.#.#.#.###.###.#####.#.#######.###.#.#.#####.#.#########.###.#.# +#.#...#.......#...#...#...#...#.#.....#...#.#.#.....#.#.#...#...#...#...#...#...#.#.#...#.........#.#.....#.#...#.#...#...#...#.......#.....# +#.#.#.#######.###.#####.#.###.#.#.#######.#.#.#####.###.###.#.###.###.#########.###.#.###.#.#######.#.###.###.###.###.#.#.#.#.#######.#.#.### +#.#.#.......#.#.#.#...#.#.......#.......#.....#...#...#...#...#.#.....#...#.....#...#.#.....#...#...#...#...........#.#.#.#.#.#.....#...#...# +#.#.###.#####.#.#.#.#.#.#.#########.###.#####.###.###.#.#.#####.#######.###.#####.###.#####.#.#.#######.#.#.#####.###.#.#.#.#.#.###.###.#.#.# +#...#.#.........#...#.#...........#...#.....#...#...#...#.#.........#.....#.#.....#.#.....#.#.#.......#.#...#...#.......#.#.#...#.#.#.....#.# +#.#.#.###############.#.#.#.#####.#####.###.###.#.#.#####.#######.#.#.###.#.#.#####.#####.#.#.#######.#.###.#.#.###.#####.#.#.###.#.#.#.#.#.# +#.#...#.....#.#...#...#.#...#...#.....#...............................#...#.............#...#...#.................#.#...#...#.....#.....#...# +#.#.#.###.#.#.#.#.#.#####.###.#.#####.#.#.#.###.###.#######.#.#####.###.#.#########.#####.#.###.#####.###.###.###.#.#.#.#.#.###########.#.#.# +#.#.#...#.#.....#...#.....#...#.#...#.#...#.#...#...#.......#.#...#.....#...#.............#...#.....#.#...#...#...#.#.....#.......#.......#.# +#.#.###.#.###.#.#####.#####.###.#.###.#####.#.###.#.#.#######.#.#.###.#######.#############.#.#.###.#.#.#.#.###.#.###.###.#.#####.#.###.##### +#...#.#...#...#...#...#.....#...#.#...#...#.#.#...#.#.#.......#.#.#...#.......#.....#.........#...#.#...#.#.#.#.#.#...#.#.........#...#.#...# +#.###.#####.#####.#.#######.#.#.#.#.###.#.#.#.###.###.#.#####.#.###.#.#.#######.###.#.###########.#.#######.#.#.#.#.###.#.#####.#.###.#.#.#.# +#...#.......#...#.........#.#.....#.....#.#.#.#...#...#.#...#.#.....#...#.....#.#...#.#...#.....#.#.......#.#.#.#.#.....#.#.....#.#...#...#.# +#.#.#.#######.###########.#.#####.#######.#.#.#.###.#####.#.#.#######.#.#.#.###.#.#.#.#.#.#.###.#.#.#####.#.#.#.#######.#.#.###.#.#.###.#.#.# +#.#...........#...#.....#.#...#.......#...#...#...#.#.....#...#.......#...#.....#.#.#.....#.#.#...#...#...#...........#.#...#...#.#.......#.# +#.###########.#.#.###.###.###.#########.#.#.###.#.#.#.###.#####.#######.#########.#####.#.#.#.#######.#.###.#####.###.#.#####.#.#.#.###.#.#.# +#.......#.....#.#.............#.........#.#.#...#.#.#...#.#...#.....#.#.#...#...#.......#.#...#.....#.#.....#...#...#.....#...#...#.........# +#.#####.#######.###.#.#######.#.#########.#.#.###.#.###.#.#.#.#.###.#.#.#.###.#.###.#.#.#.###.###.#.#.#######.#.#######.#.#.###.#######.#.#.# +#...#.#...#.....#...#.....#.#.#...#...#...#.....#.......#.#.#.#...#.#...#.#...#...#.#...#...#.....#.......#...#.......#.....#.#.#.......#.#.# +###.#.###.#.#####.#####.#.#.#.###.#.#.#.#######.#.#########.#.#.###.#.###.#.#####.###.#####.#############.#.#######.#.#####.#.#.#######.#.#.# +#...#.......#...#...#...#.#.....#...#.#.....#...#.#.........#.#.#...#.#...#.#.........#.....#...........#.#.#.#.............#.#.....#.....#.# +#.#.#####.#.###.###.#.###.#######.#.#.###.#.#.###.#.###.#####.#.#.###.###.#.###########.#####.#########.###.#.#.#############.#.###.#.#.#.#.# +#.#.....#.........#...#.#.......#.#.#...#.#.#.#...#.....#.....#.#...#.....#...#.........#.....#.......#.....#...............#...#.#.#.....#.# +#.#.###.#.###.#########.#######.#.#.###.###.#.###.#####.#.#########.###.#.###.#.###########.###.#.#######.#.#####.#.#.#####.#.#.#.#.#.#.#.#.# +#...#...#...#.#...............#.#...#.#.#...#...#.....#.#.#.......#.#.......#.#...#.........#...#.#.......#.......#.#.#.#...#.#...#.#.#...#.# +#####.###.#.###.#########.###.#.###.#.#.#.#####.#######.#.#.#####.#.#######.#.###.#####.#####.#####.#############.###.#.#.###.#.###.###.#.#.# +#.....#...#.....#...#...#...#.#.#...#.#.#...............#...#...#.#.....#...#...#.........#...#.....#.......#.........#.#...#.........#...#.# +#.#####.#.#######.#.###.###.#.#.#.###.#.#####.###############.###.#.###.###.#.#.#####.#.#.#.#.#.#####.#.#.#.#.###.#.###.###.###.#####.###.### +#...#.#.......#...#.....#...#.#.#.#...#.#.............#.......#...#...#...#.#.#.#.#...#.#.#.#.#.#.....#...#...#...#.....#.#.................# +###.#.###.###.#.#######.#.#.###.#.#.###.#.#####.#######.#.#####.###.###.#.#.#.#.#.#.###.#.#.#.#.###.#####.#####.#######.#.#########.###.###.# +#...#.#.....#.#.#.......#.#.#...#...#...#.#.....#.......#...#...#.....#.#.#.#.....#.....#.#...#...#.....#...#...#...#...#...#.....#.#.......# +#.###.#.#.#.#.#.#.#######.#.#.###.###.###.#.#####.#####.###.#.###.###.###.###.###.###.###.#.#.###.###.#####.#.###.#.#.###.#.#.#.###.######### +#.........#.#...#.#.....#.#.#.#...#...#...#.#.....#.....#.#...#.#...#.....#...#.....#.....#.#...#...#.#.....#...#.#.#.#...#.#.#...#...#.....# +#.#.#.#.#.#######.###.###.###.#####.###.#####.#####.#.#.#.#####.#.#.#######.###############.#.#.###.###.#######.#.#.#.#.###.#.###.###.#.###.# +#.#.#...#.#.....#...#.#...#...#.....#.......#.....#...#.#.........#...#.................#...#.#...#...#.#...#.....#.#.#.#.#.#.#...#.#...#...# +#.#.#####.#.#.#####.#.#.###.###.#####.#####.#####.#.###.#.###########.#.#####.#######.#.#####.###.###.#.#.#.#######.#.#.#.#.###.#.#.#####.#.# +#.#.....#.#.#.....#.#.#.........#...#.#...#.....#...#.#.#.........#...#.#.......#...#.#.......#.#...#.#...#.#...#...#...#.#.....#.......#.#.# +#.#####.#.#.###.###.#.#####.###.#.###.#.#######.#####.#.###########.###.###.###.#.#.#.#########.#.###.#.###.#.#.#.#######.#############.#.#.# +#...#.#.#.#.#.#.#...#.#...#.....#...#.#.......#.#.....#.#...........#.#...#.#...#.#.#...#...#.....#...#...#...#.#.#.............#...#...#...# +###.#.#.#.#.#.#.#.###.#.#.#########.#.###.###.#.#.###.#.#.#######.###.###.#.#.###.#.#.#.#.#.###.###.#########.#.###.#.#########.#.#.#.#####.# +#.....#.#.#.#.#.#.....#.#...#.....#.#.#...#...#.....#.#...#.......#.........#.....#...#.#.#...#.#...#.......#.#.....#.#.......#...#.#.....#.# +#.#####.#.#.#.#.#####.#.###.#.###.#.#.#.###.#########.#####.#####.#.###############.###.#.###.###.###.#####.#.#######.###.#########.#####.#.# +#.#.....#.#...#.......#...#.#.#...........#.#...........#...#.#...#.#.#.......#...#.#...#.#.#.....#.....#.#.#.#...#...#...#.........#.....#.# +#.#.#####.###.###########.#.#.#######.###.###.#.#########.###.#.###.#.#.#####.#.#.#.#.###.#.###########.#.#.#.#.#.#.###.#.#.#######.#.#####.# +#.#...#.....#...#.........#.#.......#.....#...#.#.........#...#.......#.#...#.#.#...#.....#.........#...#...#.#.#...#...#.#.#.....#.#.#...#.# +#.###.#####.#.###.#########.###.###.#####.#.###.#.#########.#.#######.#.#.###.#####.#.#.#.#####.###.#.###.#####.#####.#.###.#.###.###.###.#.# +#...#.....#.......#.......#.#.....#.....#.#.#...#...#.......#.........#.#.....#...#.#.#.....#...#...#...#.#.....#...#.#...#.#.#.#.........#.# +#.#####.#.#.#.#.###.#####.#.#.###.###.###.#.#######.#.#.#######.#####.#.#.#####.#.#.#.#####.#.###.###.#.#.###.###.###.###.#.#.#.###########.# +#.#...#.#.#.#.#...#.#.....#.#.#.#...#.....#.......#.#...........#.....#.#.#.....#.#.#...#.#...#.#...#.#.#.....#.....#.#...#.#.#...#...#...#.# +###.#.###.#.#.###.#.#.#####.#.#.###.#.###########.#.#######.#.###.###.#.#.#.#####.###.#.#.#####.###.###.###.#####.#.#.#.#.#.#.#.###.#.#.#.#.# +#...#.....#.#...#...#...#.#...#.....#.........#.#.#.........#.#...#.#.#.#...#...#...#.#...#.....#.#...#.#.......#.#.#...#...#.......#.#.#.#.# +#.#########.###.###.###.#.#######.#.#########.#.#.###.#.#####.###.#.#.#.#####.#####.#.###.#.#.#.#.###.#.#####.#.###.###.###.#.#.#.###.#.#.#.# +#.....#.......#.#.....#...#.......#...#...#.....#...#.#.#...#...#.#.........#...#.....#...#.#.#.....#.#.#.....#...#.....#.......#.#.....#...# +#####.#.###.###.#.###.#.#.###.###.###.#.#.#.#####.#.#.#.###.###.#.#######.#.#.#.#.#########.#.#######.#.#.#######.#######.#######.#########.# +#.....#.#.#...#.#...#.........#.....#.#.#.#.#...#.#.....#...#.....#.....#.#...#.#...#...#...#.........#.#.#.....#.#.......#.#...#.#...#...#.# +#.#####.#.###.#.#.#.###########.#####.#.#.#.#.#.#####.###.###.#####.###.#.###.#.#.###.#.#.#####.#######.#.#.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.# +#...#.......#.#.#.#.......#.....#.....#.#...#.#.#.....#.......#...#.....#...#.#...#...#.....#.........#...#.#.#.#...#.......#.#...#.#...#.#.# +#.#.#####.###.#.#######.###.###.#.###########.#.#.###.#.#####.#.#.###.#.###.#.#####.###.###.#.#.#####.#.###.#.#.#######.###.#.#####.#####.### +#.#...#.#.#...#...#...#...#.......#...........#.....#.#.#...#.#.#.....#.#...#.#.......#...#.#.#...#...#...#.#.#...#...#...#.................# +#.###.#.#.#.#####.#.#.###.###.#.###.#####.###########.###.#.###.#######.#.#.###.#########.#.###.#.#######.#.#.###.#.#.#####.###########.###.# +#.#...#...#.....#.#.#.#.....#.#.#...#.....#.....#...#...#.#.....#.....#...#.#...#...#.........#.#.#.....#.#.#...#.#.#.......#...........#...# +#.#.#.#########.#.#.#.#.###.#.#.#.#####.###.###.#.#.###.#.#####.#.###.#.#.#.#.###.#.#.#######.#.#.#.###.#.#.###.#.#.###.###.#####.#.#####.#.# +#.#.#.#.......#.....#...#.#.#.#.........#...#.#...#.....#...#...#...#...#.#.#...#.#.#.........#.#.....#.#.#.#...#.#.......#.......#.#.....#.# +#.#.#.#.#####.###########.#.#.#########.#.###.#########.#.#.#.#.#.#.#.#.#.#####.###.#######.###########.#.###.###.#######.#########.#.#####.# +#.#.......#...#.........#...#...#.#...#.#...#.#...........#...#.#.#.#.#.#.......#.......#...............#.....#...#.....#.#.............#...# +#####.###.#.#.#.#######.#.###.#.#.#.#.#####.#.#.###.#######.#.#.###.###.#.#######.#####.###.#.###.#####.#######.###.###.#.#####.#######.##### +#.....#.....#.#.....#...#.....#.#.#.#.......#...#.......#.....#...#.............#.....#.....#...#.#...#.#.....#...#...#.#.#...#.#...........# +#.###.#.#.#########.#.#######.#.#.#.#############.#####.#.###.###.#############.#.###.#######.#.#.#.#.#.#.###.###.###.#.#.#.#.###.#.#.#.#.#.# +#.#.#.#.............#.......#.#...#...............#...#...#.....#.#.........#...#...#.......#.#.#...#.....#.....#...#.#...#.#...#.#.#...#.#.# +#.#.#.###.#################.#.###.###.#.#############.#####.###.#.#.#######.#.#############.#.#.###############.###.#.#####.###.#.#.###.#.#.# +#.#...#.....................#...#...#.#.#.....#.......#.....#.#.#...#.....#.#.#.....#.......#.#...#...........#...#.#...#...#.#.#.#...#...#.# +#.#.#.#.#.#######.###############.###.#.###.#.#####.#.#.#####.#.#####.#.###.#.###.#.#.#######.###.#.#########.#.###.#.#.#.###.#.#.###.#.###.# +#.#.....#...#...#.#.......#.......#...#.#...#.#.....#.#.#...#...#...........#...#.#...#.......#...#.#.......#.#...#.#.#.#...#...#.#.#.......# +#.###.#.#.#.###.#.#.#####.#.#######.###.#.###.#.#####.#.#.#.#####.#############.#.#####.###.###.#.#.###.###.#.#.#.#.###.#.#.#.###.#.###.###.# +#.#...#.#.#.......#...#.#...#.....#.....#...#...#...#.#...#.......#.......#...#.#.#...#.#...#.#.#.#...#...#.#...#...#.....#.#.....#.#.......# +#.#.#.###.#.#.###.###.#.#####.###.#########.#####.###.#############.#####.###.#.#.#.#.#.#.#.#.#.#.###.###.#.#########.#.#.#.#######.#.#.###.# +#...#...#...#...#...#.#...#.....#.#.......#.....#.....#.....#.....#...#.#.....#.#...#.#.#.#.#.#.#...#.#...#.........#.#...#.#.....#...#.....# +#.###.#.###.###.#####.###.#.###.#.#.###.#.#.###.#.#######.#.#.#.###.#.#.###.###.#.###.#.#.#.#.#.#####.#####.#####.#.#.#.###.#.#.###.###.##### +#.#...#.....#...#.....#...#.#.#.#.#.#...#.#...#.#.#.......#.#.#.......#.....#...#.#.#.#.#.#...#.#...#.....#.....#.#.#.#.#...#.#.....#.......# +###.#.#######.#.#.#####.###.#.#.###.#.###.#####.#.#####.#####.#######.#######.###.#.#.#.#.###.#.#.#.#####.###.###.#.#.#.###.#.#######.#.###.# +#...#...#.....#.#.....#.#.....#.....#.#.........#...#...#.....#.....#.#.....#.#.....#.....#...#...#.....#...#.#.......#...#.....#.....#...#.# +#.###.#.#.#####.#####.#.#.###.#######.#.###########.#.###.#####.#.###.#.###.#.#.#################.###.#.###.#.#.#####.###.#####.#.#####.#.#.# +#.#.......#.#.......#...........#.#...#...#.......#.#...#.......#.....#.#.#...#.#.#.............#.#.#.#.#.#.#.#...#.#.#.#...#.#.#.....#...#.# +#.###.#####.#.#####.#.#########.#.#.###.#.#.#######.###.#.#.#####.#####.#.#####.#.#.###.#######.#.#.#.#.#.#.#.###.#.#.#.###.#.#.#####.#.###.# +#.#...#...#...#.....#...#...#.....#.....#.#...#.....#...#...#.....#.....#.....#.#.#...#.....#...#...#.#...#.#.#...#.......#.#.#...#...#...#.# +#.#.#.#.###.###.#.#.###.#.#.#########.###.###.#.#####.###.###.#.###.#####.#####.#.###.#.#.#.#.#######.###.#.###.###.#######.#.###.###.###.#.# +#...#.#.....#.#.#.#.#.#...#.....#...#.#.#...#...#.....#...#...#.....#.#.........#...#.#.#.#.#.....#...#.#.#.....#...#.....#.#...#...#.#...#.# +#####.#.#####.#.#.#.#.#####.###.#.#.#.#.###.#.###.#####.###.###.#####.#.#########.#.#.#.#.#.#####.#.###.#.#######.###.###.#.#.#####.#.#.###.# +#.....#.#.....#.#.#.......#...#.#.#.#...#...#.....#...#...#.....#.#...#.#.........#.#.#.#.#...#.#.#...#.........#...#.#.....#.#.....#.#...#.# +#.#.###.#.#####.#.#####.###.#.#.#.#.###.#.#.#######.#.###.#######.#.#.#.#.#.#######.#.#.#.###.#.#.###.#############.#.#######.#.#######.#.### +#.....#...#.....#.#.....#...#...#.#.#.....#.........#.....#...#.....#.#.#.#.#...#...#.#.#.#.#.#.#.#...#.............#.....#.......#...#.#...# +#.#.#.#####.#####.#######.#######.#.#.###.###.#############.#.#.#####.#.#.###.#.#.###.###.#.#.#.#.#.#.#.###############.#.#######.#.#.###.#.# +#...#.#.....#.#...#.......#.......#...#.#.#...#.#...#.......#.#.#...#...#.#...#.#...#...#.......#...#.#...#...........#.#...#...#...#...#.#.# +###.#.#.#####.#.###.#######.###.#######.#.#.###.#.#.#.#.#####.#.###.#####.#.###.#######.#.#######.#######.#.#########.###.#.#.#.#######.###.# +#.....#...#...#.#...#.....#.#.#.....#.....#.#.....#...#.#.....#...........#.#.#...#.....#.#.......#.......#...#.....#.....#...........#.....# +#.#.#####.###.#.#.###.###.#.#.#####.#.#####.#.#########.#.#########.#.#.###.#.#.#.#.#.#.#.#.#######.#########.#####.###.###.#####.#.#.#####.# +#.#.....#.....#.#.#...#.#.#...#.#...#.#.....#.#.........#...#.........#.#...#...#...#...#...#...#...#...#...#...#.....#...#.#...#.#.#.....#.# +#.#.###.#####.#.#.#.###.#.###.#.#.#.###.#####.#.#.#.#######.###########.#.#####.###.#.#######.#.#.###.#.#.#.###.#.###.###.#.#.#.#.#.###.###.# +#...#.............#...#...#...#...#.#...#.....#.#...#.....#.......#.....#.#.......#.#.......#.#.#.#...#.#.#...#.#...#.#...#.#.#...#...#.....# +#.#.#.#####.#.#######.#.#####.#.#.#.#.#########.#######.#.#######.#.###.#.###.#.###.#.#####.#.#.#.#.###.#.#.###.#.#.#.#.###.#.#############.# +#...#.#.....#...#.....#.....#...#.#.#.....#.....#.......#.#.....#.#.#...#...#.#.#...#.#...#...#...#.#.....#.#...#...#.#...#.#...#...#.....#.# +#.#.#.#.#######.#.#########.#####.#.#####.#.#.###.###.#####.###.#.#.#.#.###.#.#.#.###.#.#.#########.###.###.#.###.#.#####.#####.#.#.#.###.#.# +#.#...#.#.....#.#.......#.#.#.....#.#.......#.#.......#.....#.....#.#.#.#...#.#.#.#...#.#.#.......#.......#.#.#...#.......#.....#.#...#...#.# +#.#.#.###.#.#.#.#######.#.#.#.#.#####.#.#####.#.#.###.#.#####.###.#.#.#.#.###.###.#.#####.#.#.###.###.#.#.#.#.#.###########.#####.#####.##### +#.#...#...#.#.#.........#.....#.#.....#.........#...#.#.#...#...#.#.#.#...#...#...#.....#...#.#...#...#.#...#.#.#...........................# +###.#.#.###.#########.#.#######.#.#################.###.#.#####.#.#.#.#####.###.#######.#####.#.###.#.#.#.###.#.#######.#.#################.# +#.....#...#.......#...#.........#.#.#.............#.....#.....#.....#.#...#.....#.#.....#.........#.#.#.#.....#.....#...#.#...............#.# +#.#.#.###.#######.#.#####.###.###.#.#.###.#.###############.#.#######.#.#.#####.#.#.#####.#######.#.###.###########.#.#.###.#############.#.# +#.........#.....#.#.#...#...#.#.#.#.#.#...#.#...........#...#.........#.#.....#...#.....#.#.....#.#...#.#.#.......#.#.#...#...#...#.....#...# +###.#.###.#.###.#.#.#.#.#.#.#.#.#.#.#.#.#####.###.#####.#.#####.#######.#####.#########.#.#.#.#.#.###.#.#.#.###.#.#.#.###.###.###.#.###.###.# +#...........#.#.#...#.#.#.#.#...#.#...#.....#.#...#...#.#.#.....#...........#.............#.#.........#.#.#...#.#.#...#.#.....#...#.#.#...#.# +#.###.#.#.###.#.#.#.#.#.###.#.###.#.#######.#.#.###.#.#.#.#.#####.#########.#####.#########.#########.#.#.###.#.#######.#######.###.#.###.#.# +#.#.......#.....#...#.#.....#.#...#...#...#...#...#.#.#...#...#...#...#...#.#...#.#.....#...#.....#...#.#.#...#.......#...#.....#...#.#...#.# +#.#.#.#.#.#.#########.#######.#.#####.#.#.#######.#.#.###.#####.###.#.#.#.###.#.###.###.#.###.###.#####.#.#.#######.#.#.#.#.###.#.###.#.###.# +#.#.....#...#.........#.....#.#...#.#...#.......#.#.#.#...#...#.#...#...#.#.........#...#...#...#.#.....#.#...#...#.#.#.#.#.#...#.....#.....# +#.#####.#.###.###.#####.###.#.###.#.###.#.#######.#.#.#####.#.#.#.#######.#.#.#######.#####.###.#.#.###.#.###.#.#.#.#.###.#.#.###.###.####### +#.#...#...#.....#.#.#.....#.#...#.#.....#.......#...#.#.....#.#.#...#.......#.......#...#.....#.#...#.........#.#.#.#...#.#.#.....#.....#...# +#.###.#.#.#.#####.#.#.#####.###.#.#.#####.#.###.#####.#.#####.#.###.#####.###.#####.###.#######.#####.###.#####.#.#.###.#.#.#######.###.###.# +#.....#.#...#.....#...#...#.....#.#.....#.#.............#...#.....#.#...#.#...#...#...#.....#...#...#.#...#.....#.#...#...#.#.....#.#.#.#...# +#####.#.#.###.#####.###.#.#.#####.#####.###.###.#####.###.#########.#.#.#.#.#.###.#.#######.#.###.#.#.#.#.###.###.#.#.###.#.#.#.#.#.#.#.#.#.# +#.#...........#.....#...#.#.#...#.#...#.#...#.........................#.#.........#.......#.#...#.#.#...#.#...#.....#.#...#.#.#.#...#.#.#.#.# +#.#.#######.#.#.#####.###.#.#.#.#.#.#.#.#.#.#.###.#.#####.#.#########.#.#.#############.#.#.###.#.#.#####.#.#.#####.#.#.###.###.#####.#.#.### +#.......................#.#...#.#...#.#...#.......#...#...#.........#.#.#.....#...#...#.#.#.....#.#...#.#.#...#.......#...#.....#...#...#...# +#.#####.#####.#########.#.###.#.#####.###.#.#.#######.#####.#######.#.#.#.###.#.#.#.#.#.#.#.#####.###.#.#.###.#.###.#####.#######.#.#.###.#.# +#.#.....#...#.#.......#.#...#.......#.#...#.#...#...#.............#...#...#.#...#...#.#.#...#...#...................#.....#.......#.#.#...#.# +###.#.###.#.#.#.#####.#.###.#####.###.#.###.#.#.#.#.#####.#######.#######.#.#########.#.###.#.#.#.#.#####.#.#######.###.###.#####.###.#.###.# +#...#.....#.#.#...#...#.#.#.#...#.#...#...#...#.#.#.....#.#...............#.........#.#...#...#...#.....#.#.......#.......#.#...#.....#.#...# +#.#########.#.###.#.###.#.#.###.#.#.#####.###.#.#.###.###.#.#############.#######.###.###.#############.#.#.#.###.#.###.#.#.#.#.#######.#.### +#.....#.........#.#...#...................#.....#...#...#.#...#.........#.......#...#.#...#.....#...#...#.#.#.#.#.......#...#.#.#...#...#...# +#.###.#.#########.###.###.###.#.#####.#.#.#.#.#####.###.#.#####.#######.#.#####.###.#.#.###.###.###.#.###.###.#.###.###.#####.###.#.#.#####.# +#...#.#.....#.....#...#...#...#...#...#...#...#.#...#.#...#.....#.....#...#...#.....#.#.......................#.....#...#.........#.........# +#.#.#.#######.#####.###.###.#######.#########.#.#.###.#####.#####.#######.#.#.#######.#######.###.#.#####.#.###.###.#.#.###################.# +#S..#.............#.......#...................#.............#...............#.........#...........#.........#...............................# +############################################################################################################################################# diff --git a/day16_sample.txt b/day16_sample.txt @@ -0,0 +1,17 @@ +################# +#...#...#...#..E# +#.#.#.#.#.#.#.#.# +#.#.#.#...#...#.# +#.#.#.#.###.#.#.# +#...#.#.#.....#.# +#.#.#.#.#.#####.# +#.#...#.#.#.....# +#.#.#####.#.###.# +#.#.#.......#...# +#.#.###.#####.### +#.#.#...#.....#.# +#.#.#.#####.###.# +#.#.#.........#.# +#.#.#.#########.# +#S#.............# +################# diff --git a/src/main/java/day16_pt1.java b/src/main/java/day16_pt1.java @@ -0,0 +1,153 @@ +import java.nio.file.Files; +import java.nio.file.Path; +import java.io.IOException; +import java.util.*; +import java.util.stream.*; +import java.util.regex.*; + +class day16_pt1 { + enum Dir{ + North, + East, + South, + West; + + Vec unitVec() { + return switch (this) { + case North -> new Vec(0, -1); + case East -> new Vec(1, 0); + case South -> new Vec(0, 1); + case West -> new Vec(-1, 0); + }; + } + Dir opp() { + return switch(this) { + case North -> South; + case East -> West; + case South -> North; + case West -> East; + }; + } + // there's a better way with matrix multiplication + // but I'm not going to write it r.n. + int nr(Dir other) { + return switch (this) { + case North -> switch (other) { + case North -> 0; + case East -> 1; + case South -> 2; + case West -> 1; + }; + case East -> switch (other) { + case North -> 1; + case East -> 0; + case South -> 1; + case West -> 2; + }; + case South -> switch (other) { + case North -> 2; + case East -> 1; + case South -> 0; + case West -> 1; + }; + case West -> switch (other) { + case North -> 1; + case East -> 2; + case South -> 1; + case West -> 0; + }; + }; + } + } + record Point(int x, int y) { + Point add(Vec v){ + return new Point(this.x + v.x, this.y + v.y); + } + } + record Vec(int x, int y){} + public static void main(String[] args) throws IOException { + var grid = Files.readAllLines(Path.of(args[0])); + var height = grid.size(); + var width = grid.get(0).length(); + var scores = new int[height][width]; + Point start = null; + Point end = null; + for (var y=0; y<height; y++) { + for (var x=0; x<width; x++) { + scores[y][x] = Integer.MAX_VALUE; + var p = new Point(x, y); + var ch = gv(grid, p); + switch (ch) { + case 'S': + start = p; + break; + case 'E': + scores[y][x] = 0; + end = p; + break; + } + } + } + + // From the start, recurse backwards over the whole grid + // to find hte scores to each point + var dirOut = new Dir[]{null}; // surely there's a neater way + for (var dir : Dir.values()) { + var pp = end.add(dir.unitVec()); + scores[pp.y][pp.x] = 1; + markScores(grid, pp, dir.opp(), scores, dirOut); + } + + // debug + // for (int y=0;y<height;y++) { + // for (int x=0;x<width;x++) { + // var ss = scores[y][x]; + // if (ss < Integer.MAX_VALUE) { + // System.out.printf("|%05d", ss); + // } else { + // System.out.printf("| ", ss); + // } + + // } + // System.out.print('\n'); + // } + // Now simply read the score from the start point + var res = scores[start.y][start.x]; + // and twiddle for any + // initial rotation we had to do + var dd = dirOut[0]; + res += 1000 * dd.nr(Dir.East); + System.out.printf("Day 16, pt1: %d\n", res); + } + + static void markScores(List<String> grid, Point cur, Dir curDir, int[][] scores, Dir[] dirOut) { + var curScore = scores[cur.y][cur.x]; + for (var dir : Dir.values()) { + var pp = cur.add(dir.unitVec()); + var ch = gv(grid, pp); + switch (ch) { + case '#': break; // Wall, do nothing. + case 'S': + case '.': + int add = 1 + dir.opp().nr(curDir) * 1000; + var s = curScore + add; + var ss = scores[pp.y][pp.x]; + if (s < ss) { + if (ch == 'S') + dirOut[0] = dir.opp(); + scores[pp.y][pp.x] = s; + markScores(grid, pp, dir.opp(), scores, dirOut); + } + break; + } + } + } + + static int gv(List<String> grid, Point p) { + var height = grid.size(); + if (p.y < 0 || p.y >= height) return -1; + var width = grid.get(0).length(); + if (p.x < 0 || p.x >= width) return -1; + return grid.get(p.y).charAt(p.x); + } +}