Last active
June 23, 2025 14:17
-
-
Save jamtur01/3c61c29e2d42fe924ab67c1b3b62f455 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 remove-sirens [sirens] | |
(let [sorted (sort-by :end sirens)] | |
(loop [remaining sorted | |
last-end Integer/MIN_VALUE | |
keep-count 0] | |
(if (empty? remaining) | |
(- (count sirens) keep-count) | |
(let [{:keys [start end]} (first remaining)] | |
(if (>= start last-end) | |
(recur (rest remaining) end (inc keep-count)) | |
(recur (rest remaining) last-end keep-count))))))) |
This file contains hidden or 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
#'user/remove-sirens | |
user=> (remove-sirens [{:start 1 :end 5} | |
{:start 3 :end 7} | |
{:start 6 :end 9} | |
{:start 8 :end 10}]) | |
2 | |
user=> (remove-sirens [{:start 0 :end 3} | |
{:start 2 :end 4} | |
{:start 5 :end 7} | |
{:start 6 :end 8} | |
{:start 8 :end 10}]) | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment