X = the size of the largest area that isn't infinite
X = the size of the region containing all locations which have a total distance to all given coordinates of less than 10000
1, 1 1, 6 8, 3 3, 4 5, 5 8, 9
- A list of coordinates
- They may be safe or dangerous
- They exist among a 2D grid that extends infinitely in all directions
- Only the coordinates that have a finite amount of adjacent coordinates whose Manhattan distance is closest to the source coordinate are considered safe
- Outlining the steps required to render my input's 2D grid
- Step by step
- Completing step 5/5
- Filtering, counting, hoping
- Parse the input for each
- Determine the frame of the area that bounds my coordinates
- Assign each coordinate a unique symbol
- Render the 2D grid containing just the target coordinates
- Render the 2D grid with all other coordinates marked using the symbol of the target coordinate that has the closest Manhattan Distance
Steps 1-4 were straightforward.
Within a half hour, I wrote an ~14-line algorithm that generated the 2D grid with each target coordinate placed, and built a simulator to render the grid at the press of a button.
Completing step 5 would take a bit more effort.
After another half hour, I wrote another ~14-line algorithm that processed every coordinate in my 2D grid, determining its Manhattan Distance to each target coordinate, and setting either the symbol of the closest coordinate, or a
. to indicate a tie for closest targets
The last bit of work is:
- Filtering out characters that touch the edge of the visible grid, since they go on forever
- Tallying the counts of each character
- Determine the largest tally
- Cross my fingers that it's the correct answer
Determine all symbols that occupy the edge of the visible grid, since they go on forever Generate a subset of symbols, excluding the ones identified just now Create a dictionary that will store keys for each symbol in the subset, and tallies for each occurrence as values Count each instance Return the largest count
- It worked on the example input!
- It worked on my puzzle input!
- Could it be that easy?
- Yes, it could!
- My algorithm already calculates the Manhattan Distances from each target coordinate...for each cell in the framed grid
- For Part 1, I checked for the smallest number among those distances
- For Part 2, I just need to add them together and check whether the sum is less than 10000
- If it is, I'll mark the cell with a
- Else, I'll mark the cell with a
- That will hopefully reveal the region
- I solved both parts!
- I made a simulator that helped me solve each part!