adventofcode

git clone https://git.ce9e.org/adventofcode.git

commit
3853c442c3a187d57ae07d48d3c1130454d35111
parent
511459df2a9ea55e2a3831d06c784046a4efab55
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-12-25 22:05
2023-12-23

Diffstat

A 2023/23/input.txt 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A 2023/23/solution.rs 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A 2023/23/test.txt 23 +++++++++++++++++++++++

3 files changed, 290 insertions, 0 deletions


diff --git a/2023/23/input.txt b/2023/23/input.txt

@@ -0,0 +1,141 @@
   -1     1 #.###########################################################################################################################################
   -1     2 #.#...#######.....#...#...###...#...###.....###...#.......#.....#...#...........#.......#.....#...#.......#.............###...#...###...#...#
   -1     3 #.#.#.#######.###.#.#.#.#.###.#.#.#.###.###.###.#.#.#####.#.###.#.#.#.#########.#.#####.#.###.#.#.#.#####.#.###########.###.#.#.#.###.#.#.#.#
   -1     4 #...#.....#...#...#.#.#.#.#...#...#...#...#...#.#.#.#.....#...#.#.#.#...#.......#.....#.#.#...#.#.#.#...#.#.........#...#...#...#.#...#.#.#.#
   -1     5 #########.#.###.###.#.#.#.#.#########.###.###.#.#.#.#.#######.#.#.#.###.#.###########.#.#.#.###.#.#.#.#.#.#########.#.###.#######.#.###.#.#.#
   -1     6 #.........#.#...#...#.#.#.#.....#.....###.#...#.#.#.#.#...#...#...#.#...#.........#...#...#.#...#.#.#.#...###...#...#.###.......#.#.#...#.#.#
   -1     7 #.#########.#.###.###.#.#.#####.#.#######.#.###.#.#.#.#.#.#.#######.#.###########.#.#######.#.###.#.#.#######.#.#.###.#########.#.#.#.###.#.#
   -1     8 #.........#.#.###...#.#.#.#...#.#.#...#...#...#.#...#...#.#.......#.#.#.......#...#.......#.#...#.#.#.....#...#.#...#.###...###.#.#.#.#...#.#
   -1     9 #########.#.#.#####.#.#.#.#.#.#.#.#.#.#.#####.#.#########.#######.#.#.#.#####.#.#########.#.###.#.#.#####.#.###.###.#.###.#.###.#.#.#.#.###.#
   -1    10 #.........#.#...#...#.#.#.#.#.#.#.#.#...#.....#.#.........#.......#.#.#.#...#...###.....#.#.#...#...#.....#...#...#.#...#.#...#.#.#.#...#...#
   -1    11 #.#########.###.#.###.#.#.#.#.#.#.#.#####.#####.#.#########.#######.#.#.#.#.#######.###.#.#.#.#######.#######.###.#.###.#.###.#.#.#.#####.###
   -1    12 #.#...###...#...#...#...#...#.#.#.#.....#...#...#.....#...#.......#.#.#.#.#.#.>.>.#...#.#.#.#.#.......###...#...#.#.#...#...#...#...#...#.###
   -1    13 #.#.#v###.###.#####.#########.#.#.#####.###.#.#######.#.#.#######.#.#.#.#.#.#.#v#.###.#.#.#.#.#.#########.#.###.#.#.#.#####.#########.#.#.###
   -1    14 #...#.>.#...#.#...#.......#...#.#.#...#.#...#.....#...#.#.###...#.#...#...#.#.#.#...#.#.#.#.#.#.#.....#...#.>.>.#.#.#.#...#...#####...#...###
   -1    15 #####v#.###.#.#.#.#######.#.###.#.#.#.#.#.#######.#.###.#.###.#.#.#########.#.#.###.#.#.#.#.#.#.#.###.#.#####v###.#.#.#.#.###.#####.#########
   -1    16 #.....#...#.#.#.#.#...#...#...#.#.#.#...#...#...#.#...#.#.#...#.#.........#.#.#...#...#.#.#...#.#.#...#...#...#...#.#.#.#...#.#.....#...#...#
   -1    17 #.#######.#.#.#.#.#.#.#.#####.#.#.#.#######.#.#.#.###.#.#.#.###.#########.#.#.###.#####.#.#####.#.#.#####.#.###.###.#.#.###.#.#.#####.#.#.#.#
   -1    18 #.......#.#.#.#.#.#.#.#.#.....#.#.#...#.....#.#.#...#.#.#.#.#...###.....#.#.#.#...#...#...#...#.#.#.#...#.#...#.....#.#...#.#.#.#.....#...#.#
   -1    19 #######.#.#.#.#.#.#.#.#.#.#####.#.###.#.#####.#.###.#.#.#.#.#.#####.###.#.#.#.#.###.#.#####.#.#.#.#.#.#.#.###.#######.###.#.#.#.#.#########.#
   -1    20 #.......#...#.#.#.#.#.#.#...#...#.>.>.#.#...#.#.#...#.#.#...#.>.>.#.#...#.#.#.#...#.#.......#.#...#...#.#.#...#...###...#.#...#...#.....#...#
   -1    21 #.###########.#.#.#.#.#.###.#.#####v###.#.#.#.#.#.###.#.#######v#.#.#.###.#.#.###.#.#########.#########.#.#.###.#.#####.#.#########.###.#.###
   -1    22 #.....#.....#.#.#.#.#...###...#.....###...#.#.#.#...#.#.#.......#...#.#...#.#.#...#.#.........###.....#...#.....#.....#.#.#.........###...###
   -1    23 #####.#.###.#.#.#.#.###########.###########.#.#.###.#.#.#.###########.#.###.#.#.###.#.###########.###.###############.#.#.#.#################
   -1    24 #.....#.#...#...#...#.........#...........#...#.#...#...#.........###...###...#...#.#.......#...#.#...#.........#.....#...#.................#
   -1    25 #.#####.#.###########.#######.###########.#####.#.###############.###############.#.#######.#.#.#.#.###.#######.#.#########################.#
   -1    26 #.......#.....#.....#.....#...#...........#...#...#.............#.........###...#...#...#...#.#.#.#...#.......#...#...#...#.......#.......#.#
   -1    27 #############.#.###.#####.#.###.###########.#.#####.###########.#########.###.#.#####.#.#.###.#.#.###.#######.#####.#.#.#.#.#####.#.#####.#.#
   -1    28 ###...........#.#...#...#.#.###.........###.#...###.....#.....#.#.........#...#.#.....#...#...#.#...#.#...#...#...#.#...#.#.....#...#...#...#
   -1    29 ###.###########.#.###.#.#.#.###########v###.###.#######.#.###.#.#.#########.###.#.#########.###.###.#.#.#.#v###.#.#.#####.#####.#####.#.#####
   -1    30 #...#.........#.#.....#.#.#...#.....#.>.>...#...#...###...#...#...#...#...#...#.#.....#...#...#...#.#.#.#.>.>...#...#.....#####.#.....#.....#
   -1    31 #.###.#######.#.#######.#.###.#.###.#.#v#####.###.#.#######.#######.#.#.#.###.#.#####.#.#.###.###.#.#.#.###v#########.#########.#.#########.#
   -1    32 #...#.#.......#.....#...#...#.#...#.#.#...#...###.#.###...#...#.....#...#...#.#.....#.#.#...#.#...#.#.#.#...#.........###...#...#.#.........#
   -1    33 ###.#.#.###########.#.#####.#.###.#.#.###.#.#####.#.###.#.###.#.###########.#.#####.#.#.###.#.#.###.#.#.#.###.###########.#.#.###.#.#########
   -1    34 #...#.#.#...#...#...#...#...#.#...#...#...#.....#.#...#.#.#...#.........#...#...#...#.#...#.#.#...#.#.#.#.###.#.........#.#.#.....#.......###
   -1    35 #.###.#.#.#v#.#.#.#####.#.###.#.#######.#######.#.###.#.#.#.###########.#.#####.#.###v###.#.#.###.#.#.#.#.###.#.#######.#.#.#############.###
   -1    36 #.#...#...#.>.#...###...#...#.#...#...#.......#.#...#...#.#.#...#...#...#...#...#.#.>.>...#...#...#.#...#...#.#.#.......#.#.#...###.....#...#
   -1    37 #.#.#######v#########.#####.#.###.#.#.#######.#.###.#####.#v#.#.#.#.#.#####.#.###.#.#v#########.###.#######.#.#.#.#######.#.#.#.###v###.###.#
   -1    38 #.#...#.....#.......#...#...#.#...#.#.........#.#...#...#.>.>.#.#.#.#...#...#.#...#.#.###...###...#...#.....#.#.#...#...#.#...#...>.###.#...#
   -1    39 #.###.#.#####.#####.###.#.###.#.###.###########.#.###.#.###v###.#.#.###.#.###.#.###.#.###.#.#####.###.#.#####.#.###.#.#.#.#########v###.#.###
   -1    40 #.....#.....#.#.....###.#.###.#...#...........#...#...#.###...#...#...#.#...#.#.....#.....#.....#.....#...###...#...#.#.#.#...#.....###...###
   -1    41 ###########.#.#.#######.#.###.###.###########.#####.###.#####.#######.#.###.#.#################.#########.#######.###.#.#.#.#.#.#############
   -1    42 #.........#...#.....#...#...#.#...#...........#...#...#.#...#.......#...#...#.....#.............#...#...#.......#...#.#...#.#.#.............#
   -1    43 #.#######.#########.#.#####.#.#.###.###########.#.###.#.#.#.#######.#####.#######.#.#############.#.#.#.#######.###.#.#####.#.#############.#
   -1    44 #.......#...........#.....#.#...###.............#.#...#...#...#.....#...#...#.....#...........#...#...#.........###...#.....#...............#
   -1    45 #######.#################.#.#####################.#.#########.#.#####.#.###.#.###############.#.#######################.#####################
   -1    46 #...###...........#.....#.#.....#.................#.........#.#.......#...#...#...###...#.....#...#.......#...#...###...#...................#
   -1    47 #.#.#############.#.###.#.#####.#.#########################.#.###########.#####.#.###.#.#.#######.#.#####.#.#.#.#.###.###.#################.#
   -1    48 #.#...............#.#...#.#.....#...............#...........#...#.........#...#.#.#...#...#.....#...#...#...#...#...#.....#...#...#...#.....#
   -1    49 #.#################.#.###.#.###################.#.#############.#.#########.#.#.#.#.#######.###.#####.#.###########.#######.#.#.#.#.#.#.#####
   -1    50 #...#...............#...#...###...#...#...#.....#.........#...#...#.....###.#...#.#.........#...#.....#.............#.......#...#...#...#...#
   -1    51 ###.#.#################.#######.#.#.#.#.#.#.#############.#.#.#####.###.###.#####.###########.###.###################.###################.#.#
   -1    52 #...#.#...............#.###.....#...#...#...#...#...#.....#.#...###...#...#...#...###.........###.............#.....#.....................#.#
   -1    53 #.###.#.#############.#.###.#################.#.#.#.#.#####.###.#####.###.###.#.#####v#######################.#.###.#######################.#
   -1    54 #.....#.............#.#...#.#.......#.........#...#.#...#...#...#...#...#.#...#...#.>.>.#...#...###...###.....#...#.###...#.....#...#.....#.#
   -1    55 ###################.#.###.#.#.#####.#.#############.###.#.###.###.#.###.#.#.#####.#.#v#.#.#.#.#.###.#.###v#######.#.###.#.#v###.#.#.#.###.#.#
   -1    56 ###...#.............#.....#...#...#...#...........#.###...#...###.#...#.#...#.....#.#.#...#.#.#.#...#...>.>.#...#.#.#...#.>.#...#.#...###...#
   -1    57 ###.#.#.#######################.#.#####.#########.#.#######.#####.###.#.#####.#####.#.#####.#.#.#.#######v#.#.#.#.#.#.#####v#.###.###########
   -1    58 #...#...#...#.....#...#...#...#.#.#.....#...#...#...#.......#...#...#.#.....#.......#...#...#.#.#...#.....#...#...#.#.#.....#.....###...#...#
   -1    59 #.#######.#.#.###.#.#.#.#.#.#.#.#.#.#####.#.#.#.#####.#######.#.###.#.#####.###########.#.###.#.###.#.#############.#.#.#############.#.#.#.#
   -1    60 #.......#.#...#...#.#...#...#...#.#.......#...#...###.....#...#.....#...#...#.....#.....#...#.#...#.#.#.....#...###.#.#...............#...#.#
   -1    61 #######.#.#####v###.#############.###############.#######.#.###########.#.###.###.#.#######.#.###.#.#.#.###.#.#.###.#.#####################.#
   -1    62 #.....#...#...#.>.#.#.............#.....###.......#...#...#.........###.#.###...#.#.......#...###.#.#...###...#...#.#.#.....................#
   -1    63 #.###.#####.#.#v#.#.#.#############.###.###.#######.#.#.###########.###.#.#####.#.#######.#######.#.#############.#.#.#.#####################
   -1    64 #...#.#.....#...#.#.#...#.....#...#...#.#...###...#.#.#.#...###...#...#...#####.#.........#.....#...###...#.......#.#.#.....###...#...#...###
   -1    65 ###.#.#.#########.#.###.#.###.#.#.###.#.#.#####.#.#.#.#v#.#.###.#.###.#########.###########.###.#######.#.#.#######.#.#####.###.#.#.#.#.#.###
   -1    66 #...#...#.......#.#.#...#...#.#.#.###.#.#...###.#...#.>.>.#.....#.#...#...#.....#.........#...#.#.......#...###...#...#...#.....#...#...#...#
   -1    67 #.#######.#####.#.#.#.#####.#.#.#.###.#.###v###.#######v#########.#.###.#.#.#####.#######.###.#.#.#############.#.#####.#.#################.#
   -1    68 #.....#...#...#.#.#.#...#...#.#.#.#...#...>.>.#.#.......#####...#...###.#.#.......#.......#...#.#...#...........#...#...#...................#
   -1    69 #####.#.###.#.#.#.#.###.#.###.#.#.#.#######v#.#.#.###########.#.#######.#.#########.#######.###.###.#.#############.#.#######################
   -1    70 #...#...#...#...#.#.#...#...#.#.#...#.......#.#.#.........#...#.......#.#...........###...#...#.###...#.......#.....#.......................#
   -1    71 #.#.#####.#######.#.#.#####.#.#.#####.#######.#.#########.#.#########.#.###############.#.###.#.#######.#####.#.###########################.#
   -1    72 #.#.#.....#.....#...#.#.....#...#...#.....###...#...#...#.#...#.......#.#...#.........#.#...#.#.......#.....#.#.###...#...#.................#
   -1    73 #.#.#.#####.###.#####.#.#########.#.#####.#######.#.#.#.#.###.#.#######.#.#.#.#######.#.###.#.#######.#####.#.#.###.#.#.#.#.#################
   -1    74 #.#...#.....###.....#...###...#...#.#...#...#.....#.#.#.#...#.#.###...#.#.#.#.#.......#...#.#...#.....#...#.#...#...#.#.#.#...........#...###
   -1    75 #.#####.###########.#######.#.#.###.#.#.###.#.#####.#.#.###.#.#.###.#.#.#.#.#.#.#########.#.###.#.#####.#.#v#####.###.#.#.###########.#.#.###
   -1    76 #.......#...........###...#.#.#...#.#.#.#...#.....#.#.#.###...#...#.#.#...#...#...#.......#...#.#...#...#.>.>...#...#.#.#.#...#.....#...#...#
   -1    77 #########.#############.#.#.#.###.#.#.#.#.#######.#.#.#.#########v#.#.###########.#.#########.#.###.#.#####v###.###.#.#.#.#v#.#.###.#######.#
   -1    78 #####...#.........#.....#.#.#.#...#...#...#.......#.#.#...#...#.>.>.#.#...#...#...#...#.....#.#...#.#.....#...#...#.#...#.>.#...###.........#
   -1    79 #####.#.#########.#.#####.#.#.#.###########.#######.#.###.#.#.#.#v###.#.#.#.#.#.#####.#.###.#.###.#.#####.###.###.#.#######v#################
   -1    80 ###...#...........#.....#.#.#.#...#...#...#.......#.#.###...#...#...#.#.#.#.#.#...###...#...#...#.#.#.....###...#.#...#.....#...###...###...#
   -1    81 ###.###################.#.#.#.###.#.#.#.#.#######.#.#.#############.#.#.#.#.#.###.#######.#####.#.#.#.#########.#.###.#.#####.#.###.#.###.#.#
   -1    82 #...#...#...#...###.....#.#.#.....#.#.#.#.#.......#...#.............#...#...#.#...#...#...###...#.#.#.#.........#.....#.......#.....#.....#.#
   -1    83 #.###.#.#.#.#.#v###.#####.#.#######.#.#.#.#.###########.#####################.#.###.#.#.#####.###.#.#.#.###################################.#
   -1    84 #.....#...#...#.>.#.....#.#...#.....#...#.#.###.......#...#.............#.....#.###.#...#...#...#.#.#.#.#.............###.................#.#
   -1    85 ###############v#.#####.#.###.#.#########.#.###.#####.###.#.###########.#.#####v###.#####.#.###.#.#.#.#.#.###########.###.###############.#.#
   -1    86 #.......#...#...#...###.#.###.#.......#...#.....#...#.#...#.#...........#.....>.>.#.......#...#.#.#.#.#.#.#...........#...#.............#...#
   -1    87 #.#####.#.#.#.#####.###.#.###v#######.#.#########.#.#.#.###.#.#################v#.###########.#.#.#.#.#.#.#.###########.###.###########.#####
   -1    88 #.....#.#.#...#####...#.#...>.>.......#.....#.....#.#.#.....#.........#.........#.............#.#.#.#.#...#.....#######.....#...........#...#
   -1    89 #####.#.#.###########.#.#####v#############.#.#####.#.###############.#.#######################.#.#.#.#########.#############.###########.#.#
   -1    90 #.....#...#...###.....#.....#...#...#####...#...###...#...............#...#...#...###...###...#...#...#.....###.......#.......###...#...#.#.#
   -1    91 #.#########.#.###.#########.###.#.#.#####.#####.#######.#################.#.#.#.#.###.#.###.#.#########.###.#########.#.#########.#.#.#.#.#.#
   -1    92 #.........#.#...#.#...#...#.###...#.....#.#...#.......#.....#...#...#...#...#...#.....#.....#.#.......#...#...........#...........#...#...#.#
   -1    93 #########.#.###.#.#.#.#.#.#.###########.#.#.#.#######.#####.#.#.#.#.#.#.#####################.#.#####.###.#################################.#
   -1    94 #.........#.#...#...#.#.#.#.#...#.......#.#.#.......#.#.....#.#...#...#...#...###...#...#.....#.....#...#...........#...........#...#...#...#
   -1    95 #.#########.#.#######.#.#.#.#.#.#.#######.#.#######.#.#.#####.###########.#.#.###.#.#.#.#.#########.###.###########.#.#########.#.#.#.#.#.###
   -1    96 #...#.......#.....#...#.#...#.#.#.......#.#.......#...#.......#...........#.#.....#...#.#.#...#...#...#.............#.........#...#...#.#.###
   -1    97 ###.#.###########.#.###.#####.#.#######.#.#######.#############.###########.###########.#.#.#.#.#.###.#######################.#########.#.###
   -1    98 #...#.#...........#...#.#.....#.........#...#.....#...#.......#...........#...........#...#.#.#.#.....#...............#...###...#.....#...###
   -1    99 #.###.#.#############.#.#.#################.#.#####.#.#.#####.###########.###########.#####.#.#.#######.#############.#.#.#####.#.###.#######
   -1   100 #.....#...........###...#...#...#...#...###...###...#.#.....#.###.........###.........#.....#.#...#...#.###...#.......#.#.......#.#...#.....#
   -1   101 #################.#########.#.#.#.#.#.#.#########.###.#####.#.###.###########.#########.#####.###.#.#.#.###.#.#.#######.#########.#.###.###.#
   -1   102 #...............#.#...#...#...#...#...#.#...#...#.#...###...#...#...........#.....#...#.....#.###...#.#.#...#.#...#...#.#.....###.#.###.#...#
   -1   103 #.#############.#.#.#.#.#.#############.#.#.#.#.#.#.#####.#####.###########.#####.#.#.#####.#.#######.#.#.###.###.#.#.#.#.###v###.#.###.#.###
   -1   104 #.#...#...#...#...#.#.#.#.###...#.....#.#.#...#.#.#.#...#...#...#...........#...#...#.#...#.#.....###...#...#.....#.#.#...#.>.###.#.#...#...#
   -1   105 #.#.#.#.#.#.#v#####.#.#.#.###.#.#.###.#.#.#####.#.#.#.#.###.#.###.###########.#.#####.#.#.#.#####.#########.#######.#.#####.#v###.#.#.#####.#
   -1   106 #...#...#...#.>.###.#.#.#.###.#.#...#...#.....#.#.#.#.#.....#...#.......#...#.#.......#.#.#.#.....#...#####.....#...#.#...#.#...#.#.#.#.....#
   -1   107 #############v#.###.#.#.#.###.#.###v#########.#.#.#.#.#########.#######.#.#.#.#########.#.#.#.#####.#.#########.#.###.#.#.#.###.#.#.#.#.#####
   -1   108 #.............#...#.#.#.#...#.#.#.>.>.#...###.#.#.#.#.......#...###.....#.#.#.....#...#.#.#.#.....#.#...#...#...#.###.#.#.#.#...#.#.#.#.#...#
   -1   109 #.###############.#.#.#.###.#.#.#.#v#.#.#.###.#.#.#.#######.#.#####v#####.#.#####v#.#.#.#.#.#####.#.###.#.#.#.###.###.#.#.#.#.###.#.#.#.#.#.#
   -1   110 #...#...#.......#.#.#.#...#...#.#.#.#...#.#...#.#.#...#...#.#...#.>.>.....#.#...>.>.#.#.#.#.#.....#.#...#.#.#...#...#.#.#.#.#.#...#...#...#.#
   -1   111 ###.#.#.#.#####.#.#.#.###.#####.#.#.#####.#.###.#.###.#.#.#.###.#.#v#######.#.###v###.#.#.#.#.#####.#.###.#.###v###.#.#.#.#.#.#.###########.#
   -1   112 #...#.#.#.#.....#...#.#...#.....#.#...###.#...#.#.#...#.#.#.###.#.#.###...#...#...###...#...#.#...#.#.#...#.#.>.>.#.#.#.#...#...###.....#...#
   -1   113 #.###.#.#.#.#########.#.###.#####.###.###.###.#.#.#.###.#.#.###.#.#.###.#.#####.#############.#.#.#.#.#.###.#.#v#.#.#.#.###########.###.#.###
   -1   114 #.#...#.#.#.........#...###.......#...#...#...#...#...#.#...###...#.....#.#.....#.......#.....#.#...#...###...#.#...#...#.........#...#.#...#
   -1   115 #.#.###.#.#########.###############.###.###.#########.#.#################.#.#####.#####.#.#####.###############.#########.#######.###.#.###.#
   -1   116 #.#.#...#.#.........#...###.........###.#...###.......#...#.............#.#.#...#.#.....#.......#.............#...#...###.......#.....#...#.#
   -1   117 #.#.#.###.#.#########.#.###.###########.#.#####.#########.#.###########.#.#.#.#.#.#.#############.###########.###.#.#.#########.#########.#.#
   -1   118 #...#.....#...........#...#.#.........#...#...#.........#.#.#.........#.#.#.#.#.#.#...###.......#...........#...#...#...###...#.#.....###...#
   -1   119 #########################.#.#.#######.#####.#.#########.#.#.#.#######.#.#.#.#.#.#.###.###.#####.###########.###.#######.###.#.#.#.###.#######
   -1   120 #.........................#...###...#...#...#...###...#...#...###.....#...#.#.#.#.###...#.#.....#...#.......###.........#...#...#.#...#...###
   -1   121 #.###############################.#.###.#.#####.###.#.###########.#########.#.#.#.#####.#.#.#####.#.#.###################.#######.#.###.#.###
   -1   122 #.#.....................#...#.....#.....#.#.....#...#.#...#.......#...#...#...#...#...#...#.....#.#.#...................#.....#...#.....#...#
   -1   123 #.#.###################.#.#.#.###########.#.#####.###.#.#.#.#######.#.#.#.#########.#.#########.#.#.###################.#####.#.###########.#
   -1   124 #.#.#...................#.#.#.......#.....#.#...#...#.#.#.#.........#...#...#...#...#...........#.#.....................#...#...#.....#...#.#
   -1   125 #.#.#.###################.#.#######.#.#####.#.#.###.#.#.#.#################.#.#.#.###############.#######################.#.#####.###.#.#.#.#
   -1   126 #.#.#.............#...###.#...#.....#...#...#.#.###.#.#.#.#...#.............#.#.#...............#.#...#.....#...#...###...#...###...#...#...#
   -1   127 #.#.#############.#.#.###.###.#.#######.#.###.#.###.#.#.#.#.#.#.#############.#.###############.#.#.#.#.###.#.#.#.#.###.#####.#####.#########
   -1   128 #...#...#.........#.#...#...#.#...#...#.#.###.#.###.#.#.#.#.#.#...#...#...#...#.#...#.........#.#...#...###...#...#...#.#.....#...#.........#
   -1   129 #####.#.#.#########.###.###.#.###.#.#.#.#.###.#.###.#.#.#.#.#.###v#.#.#.#.#.###.#.#.#.#######.#.#####################.#.#.#####.#.#########.#
   -1   130 ###...#...#...#...#.###...#.#.###.#.#.#.#...#.#.#...#.#.#.#.#.#.>.>.#.#.#.#.#...#.#.#.....###...###...#...............#.#.#...#.#.......#...#
   -1   131 ###.#######.#.#.#.#.#####.#.#.###.#.#.#.###.#.#.#.###.#.#.#.#.#.#####.#.#.#.#.###.#.#####.#########.#.#.###############.#.#.#.#.#######.#.###
   -1   132 #...#.....#.#...#.#...###...#...#.#.#...###...#.#...#.#.#.#.#.#.#####.#.#...#.#...#.....#...#.....#.#.#.......###...###.#.#.#.#.....###...###
   -1   133 #.###.###.#.#####.###.#########.#.#.###########.###.#.#.#.#.#.#.#####.#.#####.#.#######.###.#.###.#.#.#######.###.#.###.#.#.#.#####v#########
   -1   134 #...#.#...#...#...#...#...#.....#.#.....#...#...#...#.#.#...#.#.#.....#.#.....#.#.......#...#.#...#.#.#...#...#...#...#.#...#.#...>.#...#...#
   -1   135 ###.#.#.#####.#.###.###.#.#.#####.#####.#.#.#.###.###.#.#####.#.#.#####.#.#####.#.#######v###.#.###.#.#.#.#v###.#####.#.#####.#.###v#.#.#.#.#
   -1   136 #...#.#...#...#...#.#...#...#...#.#...#...#.#...#...#.#.#...#...#.....#.#...#...#.#...#.>.>.#.#...#.#.#.#.>.>.#.###...#.###...#...#.#.#...#.#
   -1   137 #.###.###.#.#####.#.#.#######.#.#v#.#.#####.###.###.#.#.#.#.#########.#.###.#.###.#.#.#.###.#.###.#.#.#.#####.#.###.###.###.#####.#.#.#####.#
   -1   138 #...#.#...#.#.....#.#...#...#.#.>.>.#.#...#.#...#...#.#...#.....#.....#.#...#.###.#.#.#...#.#.#...#.#.#...#...#.#...#...#...#...#.#.#...#...#
   -1   139 ###.#.#.###.#.#####.###.#.#.#.#######.#.#.#.#.###.###.#########.#.#####.#.###.###.#.#.###.#.#.#.###.#.###.#.###.#.###.###.###.#.#.#.###.#.###
   -1   140 ###...#.....#.......###...#...#######...#...#.....###...........#.......#.....###...#.....#...#.....#.....#.....#.....###.....#...#.....#...#
   -1   141 ###########################################################################################################################################.#

diff --git a/2023/23/solution.rs b/2023/23/solution.rs

@@ -0,0 +1,126 @@
   -1     1 use std::collections::HashMap;
   -1     2 
   -1     3 #[path = "../lib.rs"]
   -1     4 mod lib;
   -1     5 
   -1     6 fn parse_input() -> Vec<Vec<u8>> {
   -1     7     return lib::iter_input().map(|line| {
   -1     8         return line.bytes().collect();
   -1     9     }).collect();
   -1    10 }
   -1    11 
   -1    12 fn get_neighbors(map: &Vec<Vec<u8>>, x0: usize, y0: usize, sloped: bool) -> Vec<(usize, usize, usize)> {
   -1    13     let mut result = vec![];
   -1    14     let mut queue = vec![];
   -1    15     queue.push((x0, y0, x0, y0, 0));
   -1    16 
   -1    17     while let Some((px, py, x, y, steps)) = queue.pop() {
   -1    18         if y == 0 {
   -1    19             if steps == 0 {
   -1    20                 queue.push((x, y, x, 1, 1));
   -1    21             }
   -1    22         } else if y == map.len() - 1 {
   -1    23             result.push((x, y, steps));
   -1    24         } else {
   -1    25             let mut neighbors = vec![];
   -1    26             for (nx, ny, b) in [
   -1    27                 (x + 1, y, b'>'),
   -1    28                 (x - 1, y, b'<'),
   -1    29                 (x, y + 1, b'v'),
   -1    30                 (x, y - 1, b'^'),
   -1    31             ] {
   -1    32                 if (nx, ny) != (px, py)
   -1    33                     && (!sloped || map[y][x] == b'.' || map[y][x] == b)
   -1    34                     && map[ny][nx] != b'#'
   -1    35                 {
   -1    36                     neighbors.push((nx, ny));
   -1    37                 }
   -1    38             }
   -1    39             if (x, y) == (x0, y0) || neighbors.len() == 1 {
   -1    40                 for (nx, ny) in neighbors {
   -1    41                     queue.push((x, y, nx, ny, steps + 1));
   -1    42                 }
   -1    43             } else if neighbors.len() > 0 {
   -1    44                 result.push((x, y, steps));
   -1    45             }
   -1    46         }
   -1    47     }
   -1    48     return result;
   -1    49 }
   -1    50 
   -1    51 fn map2vec(map: &HashMap<(usize, usize), Vec<(usize, usize, usize)>>) -> Vec<Vec<(usize, usize)>> {
   -1    52     let mut result: Vec<Vec<(usize, usize)>> = vec![];
   -1    53     let mut indices = HashMap::new();
   -1    54 
   -1    55     let mut keys: Vec<&(usize, usize)> = map.keys().collect();
   -1    56     keys.sort_by_key(|(x, y)| (y, x));
   -1    57 
   -1    58     for (x, y) in keys.iter() {
   -1    59         indices.insert((x, y), result.len());
   -1    60         result.push(vec![]);
   -1    61     }
   -1    62 
   -1    63     for ((x, y), n) in map.iter() {
   -1    64         let i = indices.get(&(x, y)).unwrap();
   -1    65         for (nx, ny, steps) in n {
   -1    66             let j = indices.get(&(nx, ny)).unwrap();
   -1    67             result[*i].push((*j, *steps));
   -1    68         }
   -1    69     }
   -1    70 
   -1    71     return result;
   -1    72 }
   -1    73 
   -1    74 fn get_graph(map: &Vec<Vec<u8>>, sloped: bool) -> Vec<Vec<(usize, usize)>> {
   -1    75     let mut queue = vec![];
   -1    76     let mut graph = HashMap::new();
   -1    77 
   -1    78     let y0 = 0;
   -1    79     let x0 = map[y0].iter().position(|b| *b != b'#').unwrap();
   -1    80     queue.push((x0, y0));
   -1    81 
   -1    82     while let Some((x, y)) = queue.pop() {
   -1    83         if graph.contains_key(&(x, y)) {
   -1    84             continue;
   -1    85         }
   -1    86 
   -1    87         let n = get_neighbors(map, x, y, sloped);
   -1    88         for (nx, ny, _steps) in n.iter() {
   -1    89             queue.push((*nx, *ny));
   -1    90         }
   -1    91         graph.insert((x, y), n);
   -1    92     }
   -1    93 
   -1    94     return map2vec(&graph);
   -1    95 }
   -1    96 
   -1    97 fn get_longest_path(graph: &Vec<Vec<(usize, usize)>>) -> usize {
   -1    98     assert!(graph.len() < 64);
   -1    99 
   -1   100     let mut queue = vec![];
   -1   101     queue.push((0, 1u64, 0));
   -1   102 
   -1   103     let mut result = 0;
   -1   104 
   -1   105     while let Some((i, history, steps)) = queue.pop() {
   -1   106         if i == graph.len() - 1 {
   -1   107             result = result.max(steps);
   -1   108         } else {
   -1   109             for (j, s) in graph[i].iter() {
   -1   110                 let h = history | (1 << *j);
   -1   111                 if h != history {
   -1   112                     queue.push((*j, h, steps + *s));
   -1   113                 }
   -1   114             }
   -1   115         }
   -1   116     }
   -1   117 
   -1   118     return result;
   -1   119 }
   -1   120 
   -1   121 fn main() {
   -1   122     let map = parse_input();
   -1   123 
   -1   124     println!("part1: {}", get_longest_path(&get_graph(&map, true)));
   -1   125     println!("part2: {}", get_longest_path(&get_graph(&map, false)));
   -1   126 }

diff --git a/2023/23/test.txt b/2023/23/test.txt

@@ -0,0 +1,23 @@
   -1     1 #.#####################
   -1     2 #.......#########...###
   -1     3 #######.#########.#.###
   -1     4 ###.....#.>.>.###.#.###
   -1     5 ###v#####.#v#.###.#.###
   -1     6 ###.>...#.#.#.....#...#
   -1     7 ###v###.#.#.#########.#
   -1     8 ###...#.#.#.......#...#
   -1     9 #####.#.#.#######.#.###
   -1    10 #.....#.#.#.......#...#
   -1    11 #.#####.#.#.#########v#
   -1    12 #.#...#...#...###...>.#
   -1    13 #.#.#v#######v###.###v#
   -1    14 #...#.>.#...>.>.#.###.#
   -1    15 #####v#.#.###v#.#.###.#
   -1    16 #.....#...#...#.#.#...#
   -1    17 #.#########.###.#.#.###
   -1    18 #...###...#...#...#.###
   -1    19 ###.###.#.###v#####v###
   -1    20 #...#...#.#.>.>.#.>.###
   -1    21 #.###.###.#.###.#.#v###
   -1    22 #.....###...###...#...#
   -1    23 #####################.#