Skip to main content

Day 6: Chronal Coordinates

· One min read

This problem had me thinking a little more at the start, especially in how should I determine if a location's area is finite or not. I ended up calculating the areas of each location by going through each possible coordinate in the map and finding the closest location to it, then if a location's area contained a coordinate on the border of the map, that location's area should be infinite.

So for the first part of the problem, with the area of each location, I removed those with infinite areas and returned the largest area among the remaining locations.

As for the second part of the problem, you don't need to calculate the area, you only need to loop through all the coordinates, calculate the sum of the distance to each location and count the number of coordinates for which this sum is smaller than the given maximum sum.