Created
April 21, 2010 04:59
-
-
Save jkk/373438 to your computer and use it in GitHub Desktop.
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
| (use 'clojure.contrib.duck-streams | |
| 'clojure.contrib.combinatorics) | |
| ;; pull in our word candidates (assumes a decent-quality list) | |
| (def words (set (map #(.toLowerCase %) (read-lines "/Users/tin/src/clj/words.txt")))) | |
| ;; unscramble a word | |
| (set (filter words (map (partial apply str) (permutations "rettul")))) | |
| ;; figure out the first word (four letters) | |
| (set (filter words (map (partial apply str) | |
| (mapcat permutations (combinations "skfwufnte" 4))))) | |
| ;; figure out the second word (five letters) after removing letters from the first | |
| (set (filter words (map (partial apply str) | |
| (mapcat permutations (combinations "sfuft" 5))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment