Skip to content

Instantly share code, notes, and snippets.

@tallpeak
Last active March 2, 2019 18:13
Show Gist options
  • Save tallpeak/19952b220dbff7231d5013a164633e1b to your computer and use it in GitHub Desktop.
Save tallpeak/19952b220dbff7231d5013a164633e1b to your computer and use it in GitHub Desktop.
; find the combinations of letters which have the most anagrams
; word list is from
; https://raw.githubusercontent.com/dolph/dictionary/master/enable1.txt
(ns anagrams-sort
(:require [clojure.string :as cs]) )
(def words
(let [ home (System/getenv "HOME")
filename (str home "/Downloads/enable1.txt")
words (->> filename slurp cs/split-lines)
] words )
)
(defn negate [x] (- 0 x))
(def sortwords
(->> (reduce (fn [acc word]
(update acc (apply str (sort word)) conj word))
{}
words)
(sort-by #(-> % second count negate)))
)
(take 10 sortwords)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment