Skip to content

Instantly share code, notes, and snippets.

@msszczep
Created February 20, 2016 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msszczep/5d15b2ad8efa4faebdca to your computer and use it in GitHub Desktop.
Save msszczep/5d15b2ad8efa4faebdca to your computer and use it in GitHub Desktop.
What are the most frequently used letters in English?
(->> (slurp "ni2.txt")
clojure.string/split-lines
(map clojure.string/lower-case)
(map #(map char %))
flatten
frequencies
(map #(vector (key %)
(read-string
(format "%.2f" (* 100 (/ (val %) 2251877.0))))))
(sort-by last)
reverse)
;; ([\e 10.43] [\i 8.91] [\a 8.83] [\o 7.57] [\r 7.13] [\n 7.03]
;; [\t 6.78] [\s 6.18] [\l 5.78] [\c 4.59] [\u 3.87] [\p 3.47]
;; [\m 3.13] [\d 3.02] [\h 2.85] [\y 2.29] [\g 2.09] [\b 1.79]
;; [\f 1.07] [\v 0.89] [\k 0.71] [\w 0.61] [\z 0.37] [\x 0.31] [\q 0.17] [\j 0.14])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment