mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 11:23:17 -09:00
format
This commit is contained in:
parent
bd26741879
commit
b9943d7138
@ -19,20 +19,20 @@
|
|||||||
|
|
||||||
(defn ordered? [coll]
|
(defn ordered? [coll]
|
||||||
(reduce (fn [acc el]
|
(reduce (fn [acc el]
|
||||||
(if
|
(if (some acc (orderings el))
|
||||||
(some acc (orderings el)) (reduced false)
|
(reduced false)
|
||||||
(conj acc el)))
|
(conj acc el)))
|
||||||
#{} coll))
|
#{} coll))
|
||||||
|
|
||||||
(defn order [coll]
|
(defn order [coll]
|
||||||
(reduce (fn [acc p]
|
(reduce (fn [acc el]
|
||||||
(if-let [idxs (->> (orderings p)
|
(if-let [idxs (->> (orderings el)
|
||||||
(filter #(contains? (set acc) %))
|
(filter #(contains? (set acc) %))
|
||||||
(map #(.indexOf acc %))
|
(map #(.indexOf acc %))
|
||||||
(filter #(not= % -1))
|
(filter #(not= % -1))
|
||||||
not-empty)]
|
not-empty)]
|
||||||
(c/insert-vec acc (apply min idxs) p)
|
(c/insert-vec acc (apply min idxs) el)
|
||||||
(conj acc p)))
|
(conj acc el)))
|
||||||
[] coll))
|
[] coll))
|
||||||
|
|
||||||
;; part 1
|
;; part 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user