This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-19
Channels
- # admin-announcements (1)
- # adventofcode (14)
- # announcements (2)
- # asami (7)
- # babashka (9)
- # beginners (41)
- # calva (43)
- # cider (31)
- # clerk (2)
- # clojure (34)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (166)
- # clojure-uk (7)
- # clojurescript (4)
- # datomic (1)
- # fulcro (10)
- # garden (1)
- # hoplon (2)
- # humbleui (4)
- # hyperfiddle (12)
- # jobs-discuss (6)
- # quil (6)
- # ring (6)
- # shadow-cljs (55)
- # squint (8)
- # xtdb (26)
Day 19 -- Solutions
Here's https://github.com/alexalemi/advent/blob/main/2023/clojure/p19.clj. Today's puzzle was my favorite so far. Part 2 throws us for a loop, and one that requires implementing something nontrivial, but I didn't feel as though it was too impossible to work out how to do it from scratch. It didn't feel like you needed some prior math knowledge or experience to solve part 2, you could just sorta noodle it out for yourself.
my solution is very similar, however it took me some time to figure out the off-by-one errors (top of range is 4001 vs 4000, etc.) https://github.com/erdos/advent-of-code/blob/master/2023/day19.clj
Similar as well (splitting ranges) https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2023/day19.clj
The annoying thing about Clojure core is that so few functions accept multiple sequences, only map
and mapv
do, so you always have to repackage 2 sequences into sequence of pairs then the 2-arity function cannot be used and you have to apply
. Example:
(every? true? (mapv <= [0 0 0] [4 5 5]))
https://github.com/rjray/advent-2023-clojure/blob/master/src/advent_of_code/day19.clj I wrote part 1 much like a previous years' "machine" challenge. When it came to part 2, my brain locked. I looked to a Perl solution, but had trouble adapting it due to all the in-place modification of values (ironic, since I was a hard-core Perl guy for 25+ years). I then looked to @U2E1D7WUB's solution, which bridged the gap for me.
I improved my solution to be shorter
I see that we’re all in about same ballpark as far as lines of code are concerned
I'm not much of a code-golf person, so my solutions tend to be a bit longer. I find it novel to be able to read/understand my code months/years later 🙂.
My https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2023/day_19_parts.clj.