jeff, (edited )
@jeff@phpc.social avatar

I've completed "Lavaduct Lagoon" - Day 18 - Advent of Code 2023

I spent a few hours tinkering with an approach on this one, but it was fun. I managed to get the PHP runtime for both parts under 20ms.

One of my shortest solutions once I added some AoC library functions.

https://github.com/jstanden/advent-of-code-php/blob/main/2023/18-lavaduct-lagoon/solution.php?ts=4

18+ jeff,
@jeff@phpc.social avatar

With Part 1 I had started building a 2D grid map, but figured Part 2 would blow that up (and was right).

The directions were like old pen/turtle tutorials. I converted into polygon points (676 vertices). I ran the path through the middle of the cells to include borders (0.5, 0.5 origin).

I added a function to calculate the area of irregular polygons. I expanded the path at the end to include the borders within area.

Lots of testing, but super clean + fast.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • DreamBathrooms
  • magazineikmin
  • everett
  • InstantRegret
  • rosin
  • Youngstown
  • slotface
  • love
  • khanakhh
  • kavyap
  • tacticalgear
  • GTA5RPClips
  • thenastyranch
  • modclub
  • megavids
  • mdbf
  • normalnudes
  • Durango
  • ethstaker
  • osvaldo12
  • cubers
  • ngwrru68w68
  • tester
  • anitta
  • cisconetworking
  • Leos
  • provamag3
  • JUstTest
  • All magazines