Skip to content

Instantly share code, notes, and snippets.

@jkk
Created April 21, 2010 04:59
Show Gist options
  • Select an option

  • Save jkk/373438 to your computer and use it in GitHub Desktop.

Select an option

Save jkk/373438 to your computer and use it in GitHub Desktop.
(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