Skip to content

Instantly share code, notes, and snippets.

@drcode
Created June 14, 2022 19:04
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 drcode/8e656fe07a7ef2280dae99eedc80d573 to your computer and use it in GitHub Desktop.
Save drcode/8e656fe07a7ef2280dae99eedc80d573 to your computer and use it in GitHub Desktop.
;;THE MOST: 42% of words with J in them start with J
;;THE LEAST: 1.6% of words with Y in them start with Y
;; Word list used: https://github.com/dwyl/english-words
;; Calculation in clojure as follows:
(def words (st/split (slurp "words.txt") #"\n"))
(println (sort-by :percentage-starts
(for [c (map char (map (partial + (int \a)) (range 26)))]
(let [contains (count (filter (partial some #{c})
words))
starts (count (filter (fn [word]
(= (first word) c))
words))]
{:char c
:percentage-starts (float (* 100 (/ starts contains)))}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment