Created
October 11, 2010 19:47
-
-
Save abrenk/621096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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