adventofcode

2025-12-07T22:16:28.616489Z

I had to unpin the 2021 solution threads to make room for the rest of this year

πŸ‘ 3
2025-12-07T05:07:57.932179Z

Day 7 - Solutions

narimiran 2025-12-08T09:55:45.986619Z

@abyala The current version of create-grid was created maybe a month ago, as a result of iterations of various changes over the years of solving AoC. It maybe does too many different things at once and you need to know some internal details (e.g. it produces a set for {\# :walls}, but it produces a hashmap for {#{\#} :walls} as a predicate), but I like to be prepared for different things Eric throws at us. (But there's one other waaaay waaay more complex function in there, let's see if it gets used this year....)

snyssfx 2025-12-08T11:55:45.429399Z

catching up with pattern matching

Sam Ferrell 2025-12-08T22:45:19.845929Z

https://github.com/samcf/advent-of-code/blob/main/2025-07-laboratories.clj Part 1 was refactored to use a queue since I found it a bit more readable, Part 2 looks much like @narimiran's memoized recursive approach, though I used a set of indices in the flattened grid as I am wont to do with grids

narimiran 2025-12-07T08:00:59.569699Z

@abyala Heh, I first started with the approach which you have in your refactored solution, and then decided that recursion looks nicer πŸ™‚

jurjanpaul 2025-12-07T12:03:56.324359Z

Using Advent of Code (again) for dogfooding after major upgrades earlier this year to my ClojureScript (Scittle) playground (for casual Clojure programming on your phone). I’m glad that I could tackle some overdue low hanging fruit in the process: β€˜running’ state is now displayed explicitly. https://jurjanpaul.github.io/ape-cljs-playground/?code=KGRlZiBpbnB1dAogIDs7IHRvIGJlIHJlcGxhY2VkIHdpdGggcmVhbCBpbnB1dAogICIuLi4uLi4uUy4uLi4uLi4KLi4uLi4uLi4uLi4uLi4uCi4uLi4uLi5eLi4uLi4uLgouLi4uLi4uLi4uLi4uLi4KLi4uLi4uXi5eLi4uLi4uCi4uLi4uLi4uLi4uLi4uLgouLi4uLl4uXi5eLi4uLi4KLi4uLi4uLi4uLi4uLi4uCi4uLi5eLl4uLi5eLi4uLgouLi4uLi4uLi4uLi4uLi4KLi4uXi5eLi4uXi5eLi4uCi4uLi4uLi4uLi4uLi4uLgouLl4uLi5eLi4uLi5eLi4KLi4uLi4uLi4uLi4uLi4uCi5eLl4uXi5eLl4uLi5eLgouLi4uLi4uLi4uLi4uLi4iKQoKKGRlZm4gcGFyc2UKICBbaW5wdXRdCiAgKHN0cmluZy9zcGxpdC1saW5lcyBpbnB1dCkpCgooZGVmIHBhcnNlZCAKICAocGFyc2UgaW5wdXQpKQoKKGRlZm4gcGFydDEgW10KICAobGV0IFtwIChzdHJpbmcvaW5kZXgtb2YgKGZpcnN0IHBhcnNlZCkgIlMiKV0KICAgICg6c3BsaXRzIChyZWR1Y2UgKGZuIFt7OmtleXMgW2JlYW1zIHNwbGl0c119IHJvd10KICAgICAgICAgICAgICAgICAgICAgICAobGV0IFtuZXctYmVhbXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAobWFwY2F0IChmbiBbYl0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGlmICg9ICJeIiAobnRoIHJvdyBiKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbKGRlYyBiKSAoaW5jIGIpXQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtiXSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWFtcyldCiAgICAgICAgICAgICAgICAgICAgICAgICB7OmJlYW1zIChzZXQgbmV3LWJlYW1zKQogICAgICAgICAgICAgICAgICAgICAgICAgIDpzcGxpdHMgKCsgc3BsaXRzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoLSAoY291bnQgbmV3LWJlYW1zKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGNvdW50IGJlYW1zKSkpfSkpCiAgICAgICAgICAgICAgICAgICAgIHs6YmVhbXMgW3BdCiAgICAgICAgICAgICAgICAgICAgICA6c3BsaXRzIDB9CiAgICAgICAgICAgICAgICAgICAgIChyZXN0IHBhcnNlZCkpKSkpCiAgICAgICAgICAgIAoocHJpbnRsbiAicGFydDE6IiAocGFydDEpKQoKKGRlZm4gcGFydDIgW10KICAoLT4%2BIChyZXN0IHBhcnNlZCkKICAgICAgIChyZWR1Y2UgKGZuIFtiZWFtcyByb3ddCiAgICAgICAgICAgICAgICAgKHJlZHVjZSAoZm4gW2FjYyBbYiBuXV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgKHJlZHVjZSAoZm4gW2FjYyBwXQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKHVwZGF0ZSBhY2MgcCArIG4pKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjYwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChpZiAoPSAiXiIgKG50aCByb3cgYikpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbKGRlYyBiKSAoaW5jIGIpXQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW2JdKSkpCiAgICAgICAgICAgICAgICAgICAgICAgICB7fQogICAgICAgICAgICAgICAgICAgICAgICAgYmVhbXMpKQogICAgICAgICAgICAgICB7KHN0cmluZy9pbmRleC1vZiAoZmlyc3QgcGFyc2VkKSAiUyIpIDF9KQogICAgICAgdmFscwogICAgICAgKHJlZHVjZSArKSkpCgoocHJpbnRsbiAicGFydDI6IiAocGFydDIpKQo%3D&checksum=MTU1MTE5MzI4OA%3D%3D

benoit 2025-12-07T12:44:15.345929Z

Reducing over the lines while keeping the column number of the current beams. https://github.com/benfle/advent-of-code/blob/main/src/advent_of_code/2025/07.clj

Andrew Byala 2025-12-07T17:14:51.194899Z

@narimiran Good news - both approaches are recursive, but the first solution was (cached) tree recursive. Looking forward to checking out your solution when it's up. πŸ™‚

genmeblog 2025-12-07T19:51:43.898709Z

Both parts using only one function. https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2025/day07.clj

narimiran 2025-12-07T20:04:25.932209Z

@abyala I'm a bit late as the family obligations got in the way.... https://narimiran.github.io/aoc2025/src/day07/

Andrew Byala 2025-12-07T21:51:02.027819Z

@narimiran - I'm seriously jealous of the investment you made into your aoc-utils; create-grid is sick. Also, thanks for teaching me about Clojure's PersistentQueue! Great write-up.

Logan Turner 2025-12-07T22:39:50.889099Z

Glad to see several folks converged on the (merge-with +) approach for path counts!

minikomi 2025-12-08T04:26:30.326219Z

Ah didn't realize this channel was here I did about 11 days last year in Janet so it influenced how I'm approaching clojure this year A lot of instaparse and loopr for list comprehension type accumulators [Github](https://github.com/minikomi/advent-of-code/tree/f5dcaeeef527c125c7f773dcc6d7bbb1133d2d34/2025/src/day7.clj) Day 7 is as follows :) Grammar main = field-line (<'\n'> field-line)* field-line = token+ token = (start | split | blank) start = 'S' split = '^' blank = '.' Transform (insta/transform {:main (fn [start & ns] {:start (first (keys start)) :rows (vec (remove empty? ns))}) :token first :field-line (fn [& vs] (into {} (keep-indexed (fn [idx v] (when (not= :blank v) [idx v])) vs)))} parse-tree) Part 1 (defn step1 [[current-beam-indexes beam-split-count] row] (loopr [new-beam-indexes #{} split-count beam-split-count] [beam-index current-beam-indexes] (if (row beam-index) (recur (conj new-beam-indexes (dec beam-index) (inc beam-index)) (inc split-count)) (recur (conj new-beam-indexes beam-index) split-count)))) Part 2 (def nil+ (fnil + 0)) (defn step2 [path-indexes row] (loopr [new-path-indexes {}] [[idx n] (sort-by first path-indexes)] (if (row idx) (recur (-> new-path-indexes (update (dec idx) nil+ n) (update (inc idx) nil+ n))) (recur (update new-path-indexes idx nil+ n)))))

minikomi 2025-12-08T04:27:38.611609Z

Oh man merge with + is lovely

Apple 2025-12-07T06:36:38.025859Z

why in the example it's split 21 times? i count 22 ^ and think 22 times.

Andrew Byala 2025-12-07T06:37:57.994689Z

@zengxh - in the example, the second last splitter is never actually used; there's a period above and below it.

Andrew Byala 2025-12-07T06:39:15.867859Z

My solution - I love how Clojure makes performance issues in Advent puzzles largely disappear! β€’ Blog: https://github.com/abyala/advent-2025-clojure/blob/main/docs/day07.md β€’ Code: https://github.com/abyala/advent-2025-clojure/blob/main/src/advent_2025_clojure/day07.clj

1
Apple 2025-12-07T06:40:44.669169Z

Thank you that makes sense now.

πŸ‘ 1
rjray 2025-12-07T06:41:07.045329Z

Got both done in under an hour, not counting the 15min delay incurred returning from a hockey game πŸ™‚. But I feel like my solution is more imperative than functional programming. https://github.com/rjray/advent-2025-clojure/blob/master/src/advent_of_code/day07.clj