This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-18
Channels
- # adventofcode (26)
- # announcements (3)
- # babashka (12)
- # beginners (20)
- # biff (33)
- # cider (4)
- # clj-kondo (9)
- # cljdoc (17)
- # clojure (35)
- # clojure-art (6)
- # clojure-belgium (1)
- # clojure-denmark (1)
- # clojure-europe (1)
- # clojure-norway (25)
- # clojurescript (29)
- # conjure (19)
- # cryogen (1)
- # datomic (23)
- # honeysql (2)
- # java (3)
- # joyride (9)
- # lsp (24)
- # malli (3)
- # nbb (2)
- # off-topic (25)
- # pathom (2)
- # pedestal (8)
- # portal (1)
- # practicalli (7)
- # re-frame (1)
- # reitit (4)
- # releases (1)
- # shadow-cljs (14)
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.
@U0954HGDQ 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
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
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))
nice catch
(->> (parse large-example)
(mapcat surfaces)
(frequencies)
(filter #(== (second %) 1))
(count))
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 🎉
Well my flood fill seems to work so I’m curious what I’m missing for the second part.
Day 18 https://github.com/bhauman/advent-of-code-2022/blob/main/src/adv2022/day18/sol.clj
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
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