Skip to content

Instantly share code, notes, and snippets.

@odyssomay
Created May 30, 2011 20:41
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 odyssomay/999430 to your computer and use it in GitHub Desktop.
Save odyssomay/999430 to your computer and use it in GitHub Desktop.
Find strings of length 3 which differ in one position
(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