partition and inject intersection &:& 👯‍♂️ - Day 13 - Advent of Code 2023

In this episode, we solve day 13 of Advent of Code 2023, called "Point of Incidence", where we're trying to find lines of symmetry in patterns of dots and pound signs representing mirrors on Lava Island.

First, we parse the input into arrays of character arrays representing each pattern. Then we write some methods to check if a line is symmetrical around a given point, find all points of symmetry on a line, and ultimately find lines of symmetry in a full pattern.

The key is finding the intersection of symmetry points across all lines to pinpoint the overall symmetry. We handle both horizontal and vertical lines of symmetry.

For part 1, we report the number of rows above or columns left of the symmetry lines.

For part 2, we consider smudges - swapping one character in the pattern and rechecking for other valid lines of symmetry. We brute force check all possibilities, collect the new lines, and subtract out ones we already had.

In the end, we arrive at working solutions for both parts, matching the provided examples.

Advent of Code:
My Solutions:

#adventofcode #ruby