Advent of Code 2023 (Day13)

Advent of Code 2023 (Day13)


Rust

I still had to take my time to comprehend the problem description each time - but I managed to pass it.

Day13
  1. From top of the grid, compare each row. If row[i] == row[i+1], then the two might be the pair we are looking for.

  2. Calculate the boundary. To do that, compare i (the num of rows you have upward) and grid.length - i - 2 (the num of rows you have downward) and pick up the smaller one.

  3. Set j = 1 and compare row[i-j] and row[i+1+j]. If the two are not the same, the i is not the horizontal line you want -> back to #1. If the two are the same, then increment j and compare them until they reaches the boundary.

  4. If the two reaches the boundary, it means you found the horizontal line index.

  5. Just do the same way to columns in the grid.

Here is my code.

Thanks for reading ✌️

© 2024 Hiro