@ramsey Sure, that's possible. I'll check if PDO avoids the issue, but a glance at the docs seems like ATTR_TIMEOUT doesn't make a connection / read distinction for MySQL either.
The bug report proposes a reasonable change of including the max-time-to-first-byte in the connection timeout so connect/read are properly decoupled. RDS has had this issue a few times (probably load balancer related).
Cerb is likely older than PDO, so that's not an easy change. I'd break more than I fix. 😅
I've completed "Never Tell Me The Odds" - Day 24 - Advent of Code 2023 #AdventOfCode#PHP
I'd already finished this one with Python+Z3, but that felt like cheating. I had some free time today to understand the math and do a pure PHP solution for Part 2.
The input was short enough to put all the blocks in a hash table for intersections.
I wrote quick functions to get blocks from bricks, and to register/unregister those blocks from an interchangeable state. A brick could move down if its projected block locations didn't intersect any other blocks.
I used a generator to get blocks, but used 'return' rather than 'yield' when the ends were the same; which took too long to find.
Part 1 was just BFS outward from the start point. After visualizing ASCII output in the first few mins I spotted the chessboard pattern and used modulo.
Part 2 started out simple. It only took ~4 lines to convert my Grid2d class into InfiniteGrid2d w/ modulo magic.
I got bogged down trying to generalize the solution w/o catching the grid cycles radiating around the starting grid.
I took my first Reddit hint on Lagrange polynomial interpolation and learned something 🤓
@jeff ha yes, better to find the cycle inside. I hoped I could leave my code run, but after I saw your answer value, I need to update my code for a better solution. But to late for now.
For the rest, again, we have the same logic (apart queue outside the modules) , but we have almost the same namings 😁
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.
I lost some time on this one trying to figure out why I was getting a shorter path than the example. It turned out I missed the constraint that the crucible can't U-turn.
A* was happy to backtrack one tile at a cost of 3 to reset the step counter, rather than taking a multiple turn detour.
Adding the min/max steps in Part 2 was easy after the hassle of debugging Part 1.
It still takes about 10 sec to run both parts and needs some optimization.
I've completed "Parabolic Reflector Dish" - Day 14 - Advent of Code 2023 #AdventOfCode#PHP
My GridMap2d class made this much easier. The same premise was used in at least two puzzles last year, so I had a good idea of what I needed to do going into it.
With my GridMap2d class, part 1 was barely 10 commands. Find 'O' tiles starting from the northmost. Slide them up until they hit an obstacle. Calc load.
In Part 2 I had fun on the 4-way tilt code. Useful for later.
Rather than running 1B cycles, I assumed we'd find a (prime-length) cycle in the load values after a short stabilization period.
I saved load every 10 sims, and checked for cycles every 100. Found in <1500.