Created
May 30, 2011 20:41
-
-
Save odyssomay/999430 to your computer and use it in GitHub Desktop.
Find strings of length 3 which differ in one position
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 diff-by-1 [strings] | |
(let [f (partition-by first (sort-by first strings)) | |
s (partition-by second (sort-by second strings)) | |
l (partition-by last (sort-by last strings)) | |
fs (map #(partition-by second (sort-by second %)) f) | |
fl (map #(partition-by last (sort-by last %)) f) | |
sl (map #(partition-by last (sort-by last %)) s) | |
all (concat fs fl sl)] | |
(remove #(= (count %) 1) (apply concat all)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment