Last active
April 22, 2022 16:51
-
-
Save Crowbrammer/fb3c171ffdfa0224827a95c68ab1e0ee to your computer and use it in GitHub Desktop.
Sum of Intervals Solution
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
(defn sum-intervals | |
"c describes parts of a sequence. Some parts overlap. | |
Give a sum of all the unique items in the sequence." | |
[c] | |
;; Build the items | |
;; Pour 'em all into a single collection | |
;; (Implementation: Is range inclusive or exclusive? Doesn't matter. If i) | |
;; Set 'em | |
;; Count 'em. | |
(->> (map #(range %1 %2) c) | |
(apply concat) | |
(set) | |
(count))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment