cleanup dead wip code
This commit is contained in:
parent
f66cfd752a
commit
5e61eb43fc
26
src/day9.clj
26
src/day9.clj
@ -48,32 +48,6 @@
|
||||
(-> 9 get-input string/trim blocks defrag fs-checksum)))
|
||||
|
||||
|
||||
(defn blocks2 [dm]
|
||||
(loop [file? true
|
||||
file-id 0
|
||||
dm (vec dm)
|
||||
bs []]
|
||||
(if (empty? dm)
|
||||
bs
|
||||
(let [cur (parse-long (str (first dm)))]
|
||||
(if file?
|
||||
(recur false (inc file-id) (rest dm) (conj bs (take cur (repeat file-id))))
|
||||
(recur true file-id (rest dm) (conj bs (take cur (repeat \.)))))))))
|
||||
|
||||
(defn free? [span]
|
||||
(when (or (empty? span)
|
||||
(= \. (first span)))
|
||||
true))
|
||||
|
||||
(defn suitable? [f span]
|
||||
(if (free? span)
|
||||
(if (> (count f) (count span))
|
||||
false true)
|
||||
false))
|
||||
|
||||
(defn find-free-space [bs f]
|
||||
(split-with #(not (suitable? f %)) bs))
|
||||
|
||||
(defn write-blocks [bs range val]
|
||||
(reduce (fn [bs idx] (assoc bs idx val)) bs range))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user