Fork me on GitHub
#adventofcode
<
2023-12-19
>
Alex Alemi06:12:49

Day 19 -- Solutions

Alex Alemi06:12:06

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.

👍 1
erdos06:12:00

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

roklenarcic10:12:39

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

rjray18:12:37

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.

1
👍 1
roklenarcic19:12:17

I improved my solution to be shorter

roklenarcic19:12:14

I see that we’re all in about same ballpark as far as lines of code are concerned

rjray19:12:34

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

bhauman07:12:54

well that was interesting. I really have to make sure I know where I’m going before I start coding 🙂