Skip to content

Instantly share code, notes, and snippets.

@tzach
Last active September 20, 2023 14:13
Show Gist options
  • Save tzach/734a46250d86ff1216bc7efff4fa7e4e to your computer and use it in GitHub Desktop.
Save tzach/734a46250d86ff1216bc7efff4fa7e4e to your computer and use it in GitHub Desktop.
Find the max number of consecutive double letters in an English words
(defn count-consecutive-doubles [word]
{word
(->> word
(partition-by identity)
(map count)
(filter #(>= % 2))
count
)})
(with-open [rdr (clojure.java.io/reader "/home/tzach/Downloads/words.txt")]
(->> rdr
line-seq
(map count-consecutive-doubles)
(into {})
(filter #(-> % val (>= 4)))))
;; words.txt from https://github.com/dwyl/english-words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment