A bit late today, as I was at the Snowflake Christmas Party! βοΈπ₯³ It's not past midnight yet, though, so I'm still on time π. Today's challenge ( Day 3 ) was very interesting. When I first read it, I had no clue about how to solve it, and it looked almost impossible. I just had the feeling that it could be solved in SQL, but I didn't really know where to start. In the end, it turned out to be a really nice exercise in thinking geometrically with SQL.
The challenge in brief
The puzzle gives a map of a forest: a grid where each position is either a tree ( # ) or just ground ( . ). The goal is to count how many times four trees sit exactly at the four corners of a grid-aligned square. Since we're going to talk a lot about edges and geometry, from now on I'll call the corners by their geometric name: vertexes. For example, this map contains 5 squares, four small ones and a large one:
#.#.# ..... #.#.# .....β¦