https://clews.id.au/
Four failed approaches later, I finally learned this could be solved with Integer Linear Programming.
More details:
clews.id.au/til/integer-...
#AdventOfCode #Rust
Four failed approaches later, I finally learned this could be solved with Integer Linear Programming.
More details:
clews.id.au/til/integer-...
#AdventOfCode #Rust
- Flood fill: 60+ sec (didn't finish)
- Coordinate compression: Buggy
- Geo crate: 4.4s, 31 dependencies
- Custom geometry: 2.6s, ZERO dependencies! 🎉
The custom solution was 1.7x FASTER than the library!
- Flood fill: 60+ sec (didn't finish)
- Coordinate compression: Buggy
- Geo crate: 4.4s, 31 dependencies
- Custom geometry: 2.6s, ZERO dependencies! 🎉
The custom solution was 1.7x FASTER than the library!
- Ray casting for point-in-polygon
- Edge-rectangle intersection tests
- Rectilinear polygon containment check
~130 lines of careful geometry code. Worth it?
- Ray casting for point-in-polygon
- Edge-rectangle intersection tests
- Rectilinear polygon containment check
~130 lines of careful geometry code. Worth it?
Added Rust's geo crate, rewrote Part 2 to use Polygon.contains().
Result! Correct answer in 4.4 seconds!
But... 31 transitive dependencies for one function? 🤔
Added Rust's geo crate, rewrote Part 2 to use Polygon.contains().
Result! Correct answer in 4.4 seconds!
But... 31 transitive dependencies for one function? 🤔
Implemented it... incorrectly. The mapping bugs were gnarly. 😤
Implemented it... incorrectly. The mapping bugs were gnarly. 😤
Time to pivot!
Time to pivot!
Started with what seemed obvious: flood fill to find all green tiles, then check each rectangle. Simple, right?
Wrong. 60+ seconds and still running... 😅
Started with what seemed obvious: flood fill to find all green tiles, then check each rectangle. Simple, right?
Wrong. 60+ seconds and still running... 😅