Last active
September 20, 2023 14:13
-
-
Save tzach/734a46250d86ff1216bc7efff4fa7e4e to your computer and use it in GitHub Desktop.
Find the max number of consecutive double letters in an English words
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
(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