drgeraint,
@drgeraint@glasgow.social avatar

I just completed "Trebuchet?!" - Day 1 - Advent of Code 2023 https://adventofcode.com/2023/day/1

I don't think I'll have time to do many of these puzzles this year, but I'll upload any that I do to:
https://github.com/drgeraint/adventofcode2023

drgeraint,
@drgeraint@glasgow.social avatar
drgeraint,
@drgeraint@glasgow.social avatar
drgeraint,
@drgeraint@glasgow.social avatar
drgeraint,
@drgeraint@glasgow.social avatar

I just completed "If You Give A Seed A Fertilizer" - Day 5 - Advent of Code 2023 https://adventofcode.com/2023/day/5

https://github.com/drgeraint/adventofcode2023/tree/main/day05

drgeraint,
@drgeraint@glasgow.social avatar
drgeraint,
@drgeraint@glasgow.social avatar
drgeraint,
@drgeraint@glasgow.social avatar
18+ drgeraint,
@drgeraint@glasgow.social avatar

Meh, I didn't enjoy that one as much as the others so far this year.

The efficient solution depends on properties of the input data (which are not hinted in the specification) so it is not a general solution.

Also, lcm.reduce in numpy seems to give different results each time the code is run; no idea why, but I had to use Octave for the final step.

18+ jeff,
@jeff@phpc.social avatar

@drgeraint I was just happy I noticed the lcm/primes trick right away this time (from past years).

I assume everyone's inputs have intervals that are multiples of primes, with prime length instructions.

In your code, divide your intervals by your path length. LCM those, then multiply by path length. Avoids overflow.

I had to write a quick wrapper for LCM on more than 2 ints in PHP.

let $lcm = first number

foreach(subsequent number $n) $lcm = lcm($lcm, $n)

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