pub fn y23d13(input: &str, part: u32) -> u32
Expand description
The solution for the day thirteen challenge.
We take the input as a string and a variable for the part that we’re
solving (which we ultimately transform into the number of expected
differences when checking to see if we’ve found the path: 0
in part 1
and 1
in part 2
). Then we split the input for each puzzle and parse it
into a vector of its rows and columns. We then loop through each set of
valid rows (i.e., that makes a valid path) and calculate all of the
parameters necessary to split the puzzle and compare the equality along the
dividing line. If we find the path then we increase the total accordingly.
Then we do the same process again for the columns.
§Example
// probably read this from the input file...
let input = concat!(
".#.##.#.#\n",
".##..##..\n",
".#.##.#..\n",
"#......##\n",
"#......##\n",
".#.##.#..\n",
".##..##.#\n",
);
assert_eq!(y23d13(input, 1), 4);
assert_eq!(y23d13(input, 2), 400);