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