Advent of Polygon Interactions
dev.to·6d·
Discuss: DEV
📊Algorithms
Preview
Report Post

Number 9, turn me on dead man! And... grids again. While the first part of today’s puzzle is easy to implement, the second part got me down the rabbit hole of the shapely library, GEOS computational geometry, DE-9IM matrices, ray-casting and all sorts of other wildly interesting theoretical mathematical knowledge.

Let’s dive in!

Check out my full solution for day 9 at GitHub.

Part one

As input, we get a couple of coordinates in a grid that represent red tiles:

7,1
11,1
11,7
9,7
9,5
2,5
2,3
7,3

Our job is to find the biggest rectangle that can be made using any combination of two of these coordinates, where the coordinates represent the opposite edges of the rectangle. For example, the rectangle with edge coordinates 2,5 and 9,7 runs from coordinate 2,5

Similar Posts

Loading similar posts...