adventofcode

Aleks 2023-12-21T18:57:55.068259Z

Day 21 — Solutions 😵‍💫

bhauman 2023-12-23T05:02:46.056939Z

Well that was hard! Part 2 is solved I have pages of doodles and drawings that I used to figure it out. https://github.com/bhauman/adv2023/blob/main/src/adv2023/day21/sol.clj

👏🏻 1
bhauman 2023-12-23T05:07:34.467909Z

I’m glad other folks struggled too. I didn’t want to look and see that people had done this in 5 minutes 🙂

Aleks 2023-12-21T19:01:13.508509Z

Uhhh! Finally I nailed it. My code is dirty, I’m not sure if I want to post it at all. I believe it’s the toughest day so far

rjray 2023-12-21T19:14:01.503819Z

https://github.com/rjray/advent-2023-clojure/blob/master/src/advent_of_code/day21.clj I finished last night, after (shamefully) just translating a Python solution to Clojure. As if to taunt me, the Clojure takes 2x time to run that the Python did. I look forward to seeing other solutions, because I want to understand it better than I do from just cribbing Python. 😞. (Part 1 just took me ~30 min to solve, and about 1.3s to run.)

Aleks 2023-12-21T19:23:33.922279Z

Part 1 is pretty simple, not fast but a simple solution:

(defn reached-plots [adjecent start limit]
  (->> (iterate #(set (mapcat adjecent %)) [start])
       (drop limit)
       (first)))

👍 1
genmeblog 2023-12-21T19:49:35.976419Z

I'm still at part two. First part was memoized recursive function in my case. But I like above solution, which is much simpler.

wevrem 2023-12-21T21:29:06.740769Z

I figured out a trick. My https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2023/day_21_steps.clj is super slick.

wevrem 2023-12-21T21:35:35.269829Z

Actually, it’s not “slick”, it’s very hacky. I have a lot of “magic numbers” that came from examining my input. But I suspect that it will work generally for any input.

wevrem 2023-12-21T22:00:13.685489Z

My notes.

🤯 1
wevrem 2023-12-21T22:09:53.621529Z

There is a parity to the garden plots. Once they are filled up, they blink on and off, from odd to even, like a checkerboard. Also for my input (and I suspect it is true for all the inputs) there is a clear, unobstructed path directly north/south/east/west from S. So for a board of size m, in N steps we’ll reach (/ (- N (/ m 2) m) plots away from the center. My input plots were 131x131, so 26502365 steps reached (/ (- 26502365 65) 131) ;;=> 202300 plots in each direction. All the plots within a (manhattan) distance of 202299 were completely full, just had to deal with the partial plots on the outer edge of the diamond.

jurjanpaul 2023-12-27T13:09:37.845479Z

Calculated the number for a couple of board widths (relying on the fact that each generation’s number is equal to the number for the generation before the last + the number of new positions taking steps from the last ‘frontier’ that were not in the ‘frontier’ before that) and then derived the corresponding quadratic formula (not programming, so does feel like cheating) which gave me the solution.