Skip to content

stringsmedium

Top Words

150 points · 0 solved

The first line is k. Everything after it is text (any number of lines). A word is a maximal run of ASCII letters A–Z/a–z; compare words case-insensitively and print them in lowercase.

Print the k most frequent words as word count, sorted by count (highest first), breaking ties alphabetically. If there are fewer than k distinct words, print them all.

2
The cat and the hat.
The end!
the 3
and 1
Learn the technique/learn/regex-text-processing

main.py