Created
October 11, 2017 18:13
-
-
Save cemerick/44b62ef2b2e7b7bf6015cf5456cc476e to your computer and use it in GitHub Desktop.
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
(def words (set (.split (slurp "g:/words") "\n"))) | |
=> #'user/words | |
(count words) | |
=> 99171 | |
(require '[clojure.math.combinatorics :refer (permutations)]) | |
=> nil | |
(count (permutations "plates")) | |
=> 720 | |
(first (permutations "plates")) | |
=> (\p \l \a \t \e \s) | |
(defn anagrams-of [s] | |
(->> (permutations s) | |
(map #(apply str %)) | |
(filter words))) | |
=> #'user/anagrams-of | |
(anagrams-of "plates") | |
=> ("plates" "pleats" "palest" "pastel" "petals" "staple") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment