Menu

AOC 2026 - Day 3: Foggy Forest
πŸ“°

AOC 2026 - Day 3: Foggy Forest

DEV Community: sqlΒ·Davide MauriΒ·1 day ago
#PkFg1cAO
#devtosql#devto#dev#day03#col_pos
Long article (1873 words) β€” no AI summary yet.
Reading 0:00
15s threshold

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:

#.#.# ..... #.#.# .....…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.