This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-19
Channels
- # adventofcode (82)
- # beginners (70)
- # boot (34)
- # boot-dev (13)
- # cider (45)
- # clara (4)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (91)
- # clojure-art (8)
- # clojure-czech (1)
- # clojure-dusseldorf (3)
- # clojure-france (11)
- # clojure-germany (1)
- # clojure-greece (39)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-norway (2)
- # clojure-spec (7)
- # clojure-uk (31)
- # clojurescript (56)
- # core-async (7)
- # cursive (8)
- # data-science (10)
- # datomic (41)
- # duct (7)
- # emacs (1)
- # events (1)
- # fulcro (83)
- # graphql (6)
- # klipse (1)
- # leiningen (28)
- # lumo (67)
- # off-topic (14)
- # om (9)
- # onyx (3)
- # perun (4)
- # re-frame (22)
- # reagent (11)
- # ring-swagger (2)
- # rum (1)
- # specter (46)
- # sql (13)
- # uncomplicate (17)
- # unrepl (114)
Hey folks, scarce Internet access here, can someone send the part 2 instructions for day 18 as a thread comment?
Thanks!
yeah, I tend to go slowly and test things in the REPL, and I fortunately noticed this pretty early... but if you miss it, I'd imagine that you'd get weird results
especially since I was using the length of the first line to get the "shape" of the field
https://github.com/minikomi/advent-of-code/blob/master/src/advent/2017/day19.clj If you're interested 🙂
ah, I see
I just kept the data as a jagged vector, and used get-in
everywhere
heh, yeah, I know what you mean
heh, no, though I do FP in other languages
I actually think my Clojure is pretty messy
I feel like I use lazy-seq
way too often
I mean, it's really useful
but I suspect there are higher-level ways to do it
and I tend to combine lazy-seq
with letfn
I did a bunch or racket last year, so structuring things as a recursive loop often makes more sense to me
for
is pretty great
I really miss for/fold
& other racket-isms https://docs.racket-lang.org/reference/for.html
take care!
Just saves you saying (let [a.. b.. c..]
and indenting / nesting .. you can do (define a (something))
My day 19: https://github.com/orestis/adventofcode/blob/master/clojure/aoc/src/aoc/2017_day19.clj
My day 19: https://github.com/borkdude/aoc2017/blob/master/src/day19.clj (it also searches the begin position as a bonus)
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day19.clj
Day 19: https://github.com/mfikes/advent-of-code/blob/master/src/advent_2017/day_19.cljc
It seems day 18 was the most difficult: https://www.reddit.com/r/adventofcode/comments/7kuaaj/2017_day_19_leaderboard_chart/
I think the reason (for me at least) was a lack of confirmation data and lots of places where it could go wrong
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day19.clj
You can eval it in the repl, and also saves you commenting line by line, you just comment the next form, however big.
@U4P4E2FMZ C-x C-e if you’re in Emacs
Also wanted to share mine https://github.com/axelarge/advent-of-code/blob/master/src/advent_of_code/2017/day18.clj — could be optimized by running interpreters in alternating sequence instead of in parallel, but I still think it turned out pretty nice and debuggable https://github.com/axelarge/advent-of-code/blob/master/src/advent_of_code/2017/day19.clj — looks quite similar to the other ones shared I suppose
Btw get
and by extension get-in
also work on strings, so there’s no need to turn them into char vectors
I wonder if there’s a nicer way of writing the somewhat common pattern
(when (not= x bad-value) x)
For the opposite case (whitelist), there’s (some-> x #{good-values..})
Maybe something like
(defn is [pred x] (when (pred x) x))
(defn is-not [pred x] (when-not (pred x) x))
@mikelis.vindavs Clean looking solution, great job.