Skip to content

Instantly share code, notes, and snippets.

@abrenk
Created October 11, 2010 19:47
Show Gist options
  • Save abrenk/621096 to your computer and use it in GitHub Desktop.
Save abrenk/621096 to your computer and use it in GitHub Desktop.
(loop [curr 53
jobs #{98 183 37 122 14 124 65 67 199}
sum 0]
(let [[sect dist] (first
(sort-by last
(partition 2
(interleave jobs
(map
#(Math/abs (- curr %))
jobs)))))]
(if (empty? jobs)
sum
(recur
sect
(disj jobs sect)
(+ sum dist)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment