Last active
January 25, 2016 14:59
-
-
Save douglas-vaz/ff6ae5d302513f9bc730 to your computer and use it in GitHub Desktop.
Least common sorted infinite sequences
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 proc-seq [limit arg] | |
(drop-while #(< % limit) arg)) | |
(defn all-same? [xs] | |
(let [f #(= % (first xs))] | |
(every? f xs))) | |
(defn solve [& args] | |
(loop [seqs args] | |
(let [firsts (map first seqs)] | |
(if (all-same? firsts) (first firsts) | |
(recur (map (partial proc-seq (reduce max firsts)) seqs)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment