This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-14
Channels
- # adventofcode (36)
- # announcements (5)
- # atom-editor (2)
- # babashka (19)
- # beginners (98)
- # biff (7)
- # calva (25)
- # cider (1)
- # cljdoc (10)
- # clojure (70)
- # clojure-czech (1)
- # clojure-dev (14)
- # clojure-europe (79)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-seattle (3)
- # clojure-uk (2)
- # clojurescript (28)
- # community-development (44)
- # core-typed (3)
- # cursive (2)
- # datalevin (5)
- # datascript (5)
- # datomic (1)
- # dev-tooling (12)
- # emacs (14)
- # honeysql (3)
- # humbleui (11)
- # introduce-yourself (1)
- # java (1)
- # kaocha (1)
- # lsp (3)
- # malli (21)
- # matcher-combinators (2)
- # nbb (7)
- # off-topic (15)
- # portal (12)
- # reitit (4)
- # releases (1)
- # shadow-cljs (59)
- # sql (8)
- # tree-sitter (3)
This is so sloppy and fast because I want to get to bed so I can go snowboarding tomorrow. Yay! https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2022/day_14_sand.clj
My solution is coming along. Got the parsing, ASCII visualization and sand falling.. trying to sort out how to detect the termination condition
One could easily cheese it by hard coding based on your specific input.. but a general solution would be nice
adapted my solution to 2018 day 17, so I don’t know if this is necessarily the most natural algorithm. doesn’t drop a unit of sand at a time, instead keeps track of areas of flowing sand and settled sand. in 2018 the “drop at a time” approach was too slow so I’d be curious to know how long it takes today. this one is ~200ms for part 2 (could certainly speed it up by drawing whole triangles at a time when there are no obstacles!) https://github.com/callum-oakley/advent-of-code/blob/main/src/aoc/2022/14.clj
Got it! This one was very fun. https://github.com/Ramblurr/advent-of-code/blob/main/src/aoc/2022/day14.clj @U01HL2S0X71 For part 2 my input and algo takes ~4.5 seconds on my computer.
felt easier than the last few days 🎉 https://github.com/FelipeCortez/advent-of-code/blob/master/2022/14.clj
did a-step-at-a-time, got 3 seconds for both parts here (on a m1 mac, which is quite fast)
@U1EP3BZ3Q looks nice! I also remember seeing some very cool visualizations of the mountain climbing one on reddit
I didn't use a grid, but just used sets representing the blocks and so looped adding sand along the way and naively faking an infinite floor. https://github.com/wardle/aoc2022/blob/main/src/day14.clj
My part 1:
Part 2:
Pretty straightforward but you can always make your life more difficult by writing this:
(apply max (first (keys world))
to find the maximum x coord in the world instead of this
(apply max (map first (keys world)
D'oh!!!!
https://github.com/zamansky/advent2022/blob/main/src/day14.cljI got up and thought I might feel compelled (shamed?) to do major overhaul, but upon review I think my original approach holds up well, and part 2 only takes about 3s. I got rid of the debug stuff scattered throughout and cleaned up some function signatures and I’m happy with it. https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2022/day_14_sand.clj
That picture for part 2, @U02P133R2SZ, makes me wonder if it could be solved by subtracting triangles, instead of simulating grains of sand, like what @U01HL2S0X71 was saying. I haven’t done Year 2018 yet, but I seem to recall some puzzle that required adding/subtracting/combining rectangular regions. Hmmm.
@UTFAPNRPT triangles are not a problem I guess, but what about these shapes?
That’s what makes it so interesting. Is there is a way to determine from the vertical and horizontal barriers which triangles (and maybe half triangles) to add and subtract? I’m not saying I’m going to spend the brain power to go figure it out, but it seems like there might be a solution there. (Of course, that is what I thought about normalizing distress signal packets from yesterday, and that turned out to be a fool’s errand. 🙃)
You could remove the "white" triangle below horizontal lines, but then you have to manage some edge cases where sands can’t reach some areas due to vertical lines.
Day 14 https://github.com/bhauman/advent-of-code-2022/blob/main/src/adv2022/day14/sol.clj
Nothing special. Exact floor width needed (plus one for aesthetics). I did like this:
(defn simulate-add-sand [cave]
(let [box (grid/bounds cave)]
(loop [sand source]
(cond
(grid/ob? box sand) :infinite
(nil? (get cave (m/add sand [0 1]))) (recur (m/add sand [0 1]))
(nil? (get cave (m/add sand [-1 1]))) (recur (m/add sand [-1 1]))
(nil? (get cave (m/add sand [1 1]))) (recur (m/add sand [1 1]))
(= sand source) :blocked
:else (conj cave {sand \o})))))
(defn sim-p2-frames [input]
(->> (parse-cave input)
(add-floor)
(iterate simulate-add-sand)
(take-while #(not= :blocked %))))
Lots of optimizations to pursue, but I’d rather work on the Clojure2D viz.
https://github.com/tschady/advent-of-code/blob/main/src/aoc/2022/d14.cljFinally... Used java.util.TreeSet
for gathering blocking sand/rock from given column. https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2022/day14.clj Clojure2d viz part at the end.
https://github.com/betaveros/noulith (http://github.com/betaveros) https://news.ycombinator.com/item?id=33975556
It’s great. The core idea is very similar to threading (`->>`) in clojure, but with partial application as the default
(his solutions for this year are in https://github.com/betaveros/advent-of-code-2022 )
culi 8 hours ago | next [–]
I just checked the 2nd place[^0] person and they... also have their own programming language...[^1]
What's going on here? Are they just extra motivated to show off their languages? Is making your own programming language more common than I realized?
EDIT: same with the 4th place person[^2]
EDIT2: same with the 7th place[^3]. Btw this is the 4th person that's clickable so actually 3/4 leaders with their GHs linked have their own programming languages
EDIT3: jonahx pointed out I made a mistake and the 2nd place person didn't actually create Vyxal, just used (and contributed) to it
[^0]:
[^1]:
[^2]:
[^3]:
these langs (and code-golf, i.e. going for smallest program byte-size) are mind-blowing! i'd never understood it until this year (i'd always associated the term with vim-golf)
Also this solving AoC with jq! https://github.com/odnoletkov/advent-of-code-jq Discussion https://news.ycombinator.com/item?id=33963383