Today has started another advent style puzzles challenge https://hanukkah.bluebird.sh/ . First day looks fun, on the level of first week of advent of code
Day 18 - Solutions
https://github.com/benjamin-asdf/advent-of-code/blob/master/src/Y2022/day18-2.clj
Well my flood fill seems to work so I’m curious what I’m missing for the second part.
I’m also counting surfaces that are “out of bounds”
found it 😞
Day 18 https://github.com/bhauman/advent-of-code-2022/blob/main/src/adv2022/day18/sol.clj
flood https://github.com/akovantsev/adventofcode/blob/master/src/adventofcode/y2022/day18.clj#L10-L57
p2 3200ms -> 75ms https://github.com/akovantsev/adventofcode/commit/9e88dc04c34ec1b674047b310f3fd44d3aa5f8bd
https://github.com/nbardiuk/adventofcode/blob/master/2022/src/day18.clj
btw, bubbling might be way faster than flood: most of voxels are surface, and the rest would need a several-steps-long search
Probably not an ordinary solution for part 1. It was my first attempt before I realized BFS saves the day
(defn surfaces [[x y z :as coords]]
(map #(-> #{%1 (mapv + %1 %2)})
(concat (repeat 3 coords)
(repeat 3 [(inc x) (inc y) (inc z)]))
[[ 1 1 0] [ 1 0 1] [ 0 1 1]
[-1 -1 0] [-1 0 -1] [ 0 -1 -1]]))
(->> (parse large-example)
(mapcat surfaces)
(group-by identity)
(vals)
(filter #(== (count %) 1))
(count))group-by + count can be replaced with frequencies
nice catch
(->> (parse large-example)
(mapcat surfaces)
(frequencies)
(filter #(== (second %) 1))
(count))“Unfortunately, you forgot your flint and steel in another dimension.” 🧊
Today was a welcome reprieve from the last couple days: https://github.com/alexalemi/advent/blob/main/2022/clojure/p18.clj
https://github.com/FelipeCortez/advent-of-code/blob/master/2022/18.clj proud of this one 🎉
immediately not proud anymore after seeing your solutions in half the line count
I’m slowly catching up. Wrote a very concise flood function.
https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2022/day_18_droplets.clj
https://gitlab.com/maximoburrito/advent2022/-/blob/main/src/day18/main.clj I'm actually quite happy with this code for a change. Thankfully the technique suggested by the problem statement turned out to be a good direction...
I got part 1 easily-enough, but I'm getting one more air-pocket than I should when running part-2 on the example data.
It's weird-- I checked it out and the "wrong" air-pocket is in fact surrounded by blocks on all 6 faces.
@norman i like the brutal way to get the (cubic) bounds 😄
Hmmm... from reading reddit, looks like I should be doing a BFS or flood-fill. Think I'll try the BFS first.
on my input it didn’t matter, but i tried expanding the area by a lot and DFS was much much faster. It makes sense — if you want to check if you can reach the edge, try going far in one direction first vs circling around the origin
https://github.com/axelarge/advent-of-code/blob/master/src/advent_of_code/y2022/day18.clj