Copyright | (c) Eric Mertens 2023 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
https://adventofcode.com/2023/day/11
We're given a map of galaxies and need to find the sum of all distances between the pairs of galaxies. The twist is that empty rows and columns are expanded.
We can simplify this problem by solving the X and Y axes separately. We can collapse the input down to a count of how many galaxies exist at each location on a single axis.
>>>
:{
:main + "...#...... .......#.. #......... .......... ......#... .#........ .........# .......... .......#.. #...#..... " :} 374 82000210