adventofcode

nbardiuk 2022-12-18T16:22:43.367909Z

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

👀 1
2022-12-18T06:01:36.496479Z

Day 18 - Solutions

bhauman 2022-12-19T18:07:45.274759Z

Well my flood fill seems to work so I’m curious what I’m missing for the second part.

bhauman 2022-12-19T18:08:20.618949Z

I’m also counting surfaces that are “out of bounds”

bhauman 2022-12-19T19:55:26.905799Z

found it 😞

misha 2022-12-18T12:05:33.003429Z

btw, bubbling might be way faster than flood: most of voxels are surface, and the rest would need a several-steps-long search

Aleks 2022-12-18T13:08:58.473709Z

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))

Miķelis Vindavs 2022-12-18T13:09:54.629019Z

group-by + count can be replaced with frequencies

👍🏻 1
Aleks 2022-12-18T13:12:52.222359Z

nice catch

(->> (parse large-example)
     (mapcat surfaces)
     (frequencies)
     (filter #(== (second %) 1))
     (count))

Aleks 2022-12-18T13:28:24.301119Z

“Unfortunately, you forgot your flint and steel in another dimension.” 🧊

2022-12-18T14:07:05.412519Z

Today was a welcome reprieve from the last couple days: https://github.com/alexalemi/advent/blob/main/2022/clojure/p18.clj

Felipe 2022-12-18T19:19:34.488909Z

https://github.com/FelipeCortez/advent-of-code/blob/master/2022/18.clj proud of this one 🎉

Felipe 2022-12-18T19:21:27.858269Z

immediately not proud anymore after seeing your solutions in half the line count

wevrem 2022-12-24T01:32:05.544869Z

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

👏🏻 2
2022-12-18T06:04:30.086969Z

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...

rjray 2022-12-18T06:38:11.063659Z

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.

rjray 2022-12-18T06:41:02.820249Z

It's weird-- I checked it out and the "wrong" air-pocket is in fact surrounded by blocks on all 6 faces.

Miķelis Vindavs 2022-12-18T07:04:15.521379Z

@norman i like the brutal way to get the (cubic) bounds 😄

rjray 2022-12-18T07:22:51.632659Z

Hmmm... from reading reddit, looks like I should be doing a BFS or flood-fill. Think I'll try the BFS first.

Miķelis Vindavs 2022-12-18T07:23:50.809589Z

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