Skip to content

Instantly share code, notes, and snippets.

@douglas-vaz
Last active January 25, 2016 14:59
Show Gist options
  • Save douglas-vaz/ff6ae5d302513f9bc730 to your computer and use it in GitHub Desktop.
Save douglas-vaz/ff6ae5d302513f9bc730 to your computer and use it in GitHub Desktop.
Least common sorted infinite sequences
(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