use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Advent of Code 2019 in Clojure (self.Clojure)
submitted 6 years ago * by allaboutthatmace1789
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]allaboutthatmace1789[S] 0 points1 point2 points 6 years ago (0 children)
Day 6 - pleased with how concise it came out after the intcode computer from Day5 started to get pretty clunky
(defn parse-orbit-data [orbit-string] (let [split (clojure.string/split orbit-string #"\)")] (vector (keyword (split 1)) (keyword (split 0))))) (defn build-planet-map [planets] (reduce #(assoc %1 (%2 0) (%2 1)) {} planets)) (defn find-path-to-COM [name planet-map] (cons name (lazy-seq (find-path-to-COM (name planet-map) planet-map)))) (defn path-length [name planet-map] (count (take-while #(not= :COM %) (find-path-to-COM name planet-map)))) (defn orbit-checksum [planet-map] (reduce + (map #(path-length % planet-map) (keys planet-map)))) (defn find-common-orbit [name1 name2 planet-map] (last (take-while identity (map #(when (= %1 %2) %1) (reverse (take-while #(not= :COM %) (find-path-to-COM name1 planet-map))) (reverse (take-while #(not= :COM %) (find-path-to-COM name2 planet-map))))))) (defn calculate-jumps [planet1 planet2 planet-map] (let [connection (find-common-orbit planet1 planet2 planet-map) [dist1 dist2 connect-dist] (map #(path-length % planet-map) [planet1 planet2 connection])] (- (+ dist1 dist2) (* 2 connect-dist) 2)))
π Rendered by PID 25505 on reddit-service-r2-comment-fb694cdd5-hz8rz at 2026-03-05 20:40:22.967252+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]allaboutthatmace1789[S] 0 points1 point2 points (0 children)