adventofcode

2023-12-19T06:30:49.054649Z

Day 19 -- Solutions

genmeblog 2023-12-19T10:01:31.950689Z

Similar as well (splitting ranges) https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2023/day19.clj

roklenarcic 2023-12-19T10:18:39.527609Z

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

rjray 2023-12-19T18:09:37.322649Z

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 @erdos's solution, which bridged the gap for me.

πŸ‘ 1
πŸ‘πŸ» 1
roklenarcic 2023-12-19T19:33:17.434199Z

I improved my solution to be shorter

roklenarcic 2023-12-19T19:34:14.825229Z

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

rjray 2023-12-19T19:45:34.754579Z

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 πŸ™‚.

bhauman 2023-12-20T07:21:54.688829Z

well that was interesting. I really have to make sure I know where I’m going before I start coding πŸ™‚

2023-12-19T06:32:06.914659Z

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
erdos 2023-12-19T06:43:00.408009Z

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