UGH! This one seemed like a reversal, the first part was much harder than the second part.

I started out as I always do when pretending to be a video game developer: swearing loudly because my rectangles were overlapping and I forgot that it's way easier to find out if they're not overlapping.

Then I kept trying to optimize, but that wasn't getting me anywhere. I ended up brute-forcing my way through. This is ugly... maybe 25 seconds to chunk through.

After calming down a little (rectangles are dumb), I set in to work on the second part. This turned out much simpler. It was just another n^{2} with an early escape function. Almost identical to yesterday. The key is making sure our find eliminates candidates as fast as possible. Enter none, which returns false as soon as we see an overlap with our current. Yes, I was lazy and just added a quick "same id == no overlap" check instead of making sure I was checking unique pairs. I'm getting sleepy, and the first one frustrated me more than I would have liked.

I initially thought that I should use my data structure from part one to solve part 2, but while figuring it out I realized that a different structure was much more effective. I like to make my functions for the first and second parts independent anyway, so it didn’t bother me to do it again. And it came out much smaller!

## re: AoC Day 3: No Matter How You Slice It VIEW POST

FULL DISCUSSION## Kotlin Solution

UGH! This one seemed like a reversal, the first part was

muchharder than the second part.I started out as I always do when pretending to be a video game developer: swearing loudly because my rectangles were overlapping and I forgot that it's

wayeasier to find out if they're not overlapping.Then I kept trying to optimize, but that wasn't getting me anywhere. I ended up brute-forcing my way through. This is ugly... maybe 25 seconds to chunk through.

## Part 1

## Part 2

After calming down a little (rectangles are

dumb), I set in to work on the second part. This turned out much simpler. It was just another n^{2}with an early escape function. Almost identical to yesterday. The key is making sure our find eliminates candidates as fast as possible. Enter`none`

, which returns false as soon as we see an overlap with our current. Yes, I was lazy and just added a quick "same id == no overlap" check instead of making sure I was checking unique pairs. I'm getting sleepy, and the first one frustrated me more than I would have liked.From my pain, your gain! An image of the overlapping areas plotted.

I totally agree that the second part seemed

so much easierthat the first. It really threw me off.I initially thought that I should use my data structure from part one to solve part 2, but while figuring it out I realized that a different structure was much more effective. I like to make my functions for the first and second parts independent anyway, so it didn’t bother me to do it again. And it came out much smaller!