Skip to content

Instantly share code, notes, and snippets.

/lccs

Created February 19, 2013 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4983479 to your computer and use it in GitHub Desktop.
Save anonymous/4983479 to your computer and use it in GitHub Desktop.
Longest contiguous common sequence
(defn o ([s] (o s (count s))) ([s n] (map (partial take n) (take n (iterate rest (cycle s))))))
(defn lccs [a b] (reduce max (map (comp count (partial filter true?)) (map (partial map =) (repeat a) (o b)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment