This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-24
Channels
- # adventofcode (33)
- # beginners (15)
- # cider (6)
- # clara (24)
- # cljs-dev (3)
- # clojure (39)
- # clojure-france (1)
- # clojure-greece (1)
- # clojure-norway (1)
- # clojure-spec (9)
- # clojure-uk (1)
- # clojurescript (40)
- # defnpodcast (1)
- # fulcro (9)
- # hoplon (33)
- # jobs-discuss (4)
- # lumo (3)
- # off-topic (4)
- # onyx (2)
- # parinfer (7)
- # precept (45)
- # re-frame (25)
- # ring-swagger (4)
- # shadow-cljs (2)
- # specter (3)
- # sql (10)
- # uncomplicate (3)
- # unrepl (8)
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day24.clj
Yeah, that's a rare gem. I happened to use it in day 7 https://github.com/mfikes/advent-of-code/blob/202768383a22d6cb0d37ef7b73dab32b21cb8085/src/advent_2017/day_07.cljc#L27
It seems that some amount of golfing makes code easier to comprehend, but if you push it too far, you lose the balance.
@bhauman, yeah, that way I would only have to build the tree on not visit each node afterwards but only apply tree-seq on it
Didn’t think about concision, although I might try the tree-seq approach.
(time (part-1)) ;; 1859, ~5.8s
(time (part-2)) ;; 1799, ~6.4s
Little speedup by not even building a tree anymore: https://github.com/borkdude/aoc2017/blob/master/src/day24.clj#L90
(time (part-1)) ;; 1859, ~5.8s
(time (part-1')) ;; 1859 ~4.8ms
(time (part-2)) ;; 1799, ~6.4s
(time (part-2')) ;; 1799, ~5.0s
This may be how @bhauman does it too? https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day24.clj#L37 Might try his index too.
With index, 1.7s for part 2 now https://github.com/borkdude/aoc2017/blob/master/src/day24.clj#L152
Very clean solution in SQL: https://github.com/xocolatl/advent-of-code/blob/master/Day24/script.sql
https://github.com/bhauman/advent-of-clojure-2016/blob/master/src/advent_of_clojure_2017/day24.clj
it’s a very cool way of using tree-seq again, unexpected because the root you’re passing doesn’t look like a tree, but as long children and branch? return something useful it just keeps going 🙂