Last active
March 2, 2019 18:13
-
-
Save tallpeak/19952b220dbff7231d5013a164633e1b 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
; 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