diff options
Diffstat (limited to 'day12/part1.clj')
-rw-r--r-- | day12/part1.clj | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/day12/part1.clj b/day12/part1.clj index fe8ca7c..cdd4a43 100644 --- a/day12/part1.clj +++ b/day12/part1.clj @@ -7,21 +7,13 @@ (#(concat % (map reverse %))) )) -(def search-caves - (memoize (fn [id] - (filter #(= (first %) id) caves)))) - (defn get-caves-forward [klst] - (let [end (first klst)] - (if (str/starts-with? end "end") - [klst] - (map #(cons (second %) klst) - (filter - (fn [cv] - (or (< (int (first (second cv))) 96) - (not-any? #(= % (second cv)) klst))) - (search-caves end) - ))))) + (map #(cons (second %) klst) + (filter + #(or (< (int (first (second %))) 96) + (not-any? (partial = (second %)) klst)) + (filter #(= (first %) (first klst)) caves) + ))) (loop [lst (get-caves-forward ["start"]) ms '()] (let [nxt (->> lst |