jeff,
@jeff@phpc.social avatar

I've completed "The Floor Will Be Lava" - Day 16 - Advent of Code 2023

GridMap2d and Entity2d continue to come in handy.

This one had a big edge case that wasn't immediately obvious from the instructions.

https://github.com/jstanden/advent-of-code-php/blob/main/2023/16-floor-lava/solution.php?ts=2

18+ jeff,
@jeff@phpc.social avatar

I spent a few extra mins debugging the infinite loop that occurred when light bounced and split properly but entered a cycle w/o hitting an edge.

I added a second 'visited' hash to track position & heading, and avoided cycles.

I made a simple Beam class so I could clone it on the splitters and set opposing headings.

Part 2 was just an array of border starts, offsets, and headings.

There was probably a faster way, but it ended up readable and fast enough.

18+ velkuns,
@velkuns@phpc.social avatar

@jeff why rotating the heading vector and not just set it, like for splitting part ?

Probably most generic, but less simpler in this case 😁

And again, we have a very similar approach today. I also tend to use more the queue over recursion when possible, thanks to previous AoC years 👍

18+ jeff,
@jeff@phpc.social avatar

@velkuns So all of my 2d library's features feel equally loved. 😁

Yeah, I feel like I start with DFS on everything by default now.

I like your const map approach. 👍

18+ velkuns,
@velkuns@phpc.social avatar

@jeff Make sense for love 😁

SI started with if { if {} } then switch to map array for readability.

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