aboutsummaryrefslogtreecommitdiffstats
path: root/day25
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-11-30 19:55:31 -0500
committerClyne Sullivan <clyne@bitgloo.com>2022-11-30 19:55:31 -0500
commit8d43e37df99f280377bed90284d6ac2428334804 (patch)
tree3a5042c9af29da52b4bac38fd78b3ccde77a1dbc /day25
parent66ed0b9d27850dc653abc8baa75884f3de311bfa (diff)
move 2021 days to folder; update README
Diffstat (limited to 'day25')
-rw-r--r--day25/part1.clj40
1 files changed, 0 insertions, 40 deletions
diff --git a/day25/part1.clj b/day25/part1.clj
deleted file mode 100644
index df2947c..0000000
--- a/day25/part1.clj
+++ /dev/null
@@ -1,40 +0,0 @@
-(require '[clojure.string :as str])
-
-(defn cucumber-step-east [cuc-map]
- (for [cuc-row cuc-map]
- (let [shifted-cuc (str/replace cuc-row #">\." ".>")]
- (if (and (= \> (last cuc-row)) (= \. (first cuc-row)))
- (-> shifted-cuc
- (str/replace #">$" ".")
- (str/replace #"^\." ">"))
- shifted-cuc))))
-
-(defn cucumber-step-south [cuc-map]
- (let [extra-cuc-map
- (conj (vec (cons (last cuc-map) cuc-map)) (first cuc-map))
- new-extra-cuc-map
- (for [y (reverse (range 1 (count extra-cuc-map)))]
- (str/join
- (for [x (range 0 (count (first cuc-map)))]
- (cond
- (and (= \. (get-in extra-cuc-map [y x])) (= \v (get-in extra-cuc-map [(dec y) x])))
- \v
- (and (= \v (get-in extra-cuc-map [y x])) (= \. (get-in extra-cuc-map [(inc y) x])))
- \.
- :else
- (get-in extra-cuc-map [y x])))))]
- (into [] (reverse (rest new-extra-cuc-map)))))
-
-(defn cucumber-seq [cuc-map-init]
- (iterate (comp cucumber-step-south cucumber-step-east) cuc-map-init))
-
-(def input (->> (slurp "./in")
- (str/split-lines)
- (vec)))
-
-(loop [cuc-hist '() cuc-list (cucumber-seq input)]
- (let [next-cuc (first cuc-list)]
- (if (or (nil? next-cuc) (= (first cuc-hist) next-cuc))
- (println "Cucs are stuck! Steps:" (count cuc-hist))
- (recur (conj cuc-hist next-cuc) (rest cuc-list)))))
-