You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
427 B
Clojure

3 years ago
(defn median [lst]
(let [cnt (count lst)
hlf (quot cnt 2)
srt (sort lst)]
3 years ago
(cond->> (nth srt hlf)
(even? cnt)
(+ (nth srt (dec hlf)))
:true
(#(quot % 2))
3 years ago
)
)
)
3 years ago
(->> (slurp "./in") ; "16,1,2,0,4,2,7,1,2,14"
(#(clojure.string/split % #","))
(map read-string)
(#(map (partial - (median %)) %))
(map #(Math/abs %))
(apply +)
(println)
)
3 years ago