Advent of Code 2024 - Day 8Resonant Collinearity
| Problem statement | Source code | Tags: Geometry
This problem pays tribute to 2016 day 25 (unimplemented).
Part 1
I parse the input to four things: mat, a char array array, the width and height, and antenna_groups, a (char * (int * int) list) list mapping each frequency character to the list of coordinates.
Then, for each group of antennas, I get all combinations of antenna pairs and mark their antinodes on the map.
Finally, I count the number of true values in antinodes.
Part 2
Same as part 1, except now I can explore farther than one dx and dy. Because x2 = x1 + dx, y2 = y1 + dy, we can simply traverse all x1 + m * dx and y1 + m * dy until we go out of bounds.