Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using re and Counter solution in Creative category for The Most Wanted Letter by H0r4c3
import re
from collections import Counter
def checkio(text: str) -> str:
text_low = ''.join(sorted(text.lower()))
regex = re.compile('[a-z]+')
text_low_letters = re.findall(regex, text_low)
char_counts = Counter(text_low_letters[0])
dict_ord = dict(char_counts.most_common())
return list(dict_ord.keys())[0]
if __name__ == '__main__':
print("Example:")
print(checkio("Hello World!"))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio("Hello World!") == "l", "Hello test"
assert checkio("How do you do?") == "o", "O is most wanted"
assert checkio("One") == "e", "All letter only once."
assert checkio("Oops!") == "o", "Don't forget about lower case."
assert checkio("AAaooo!!!!") == "a", "Only letters."
assert checkio("abe") == "a", "The First."
print("Start the long test")
assert checkio("a" * 9000 + "b" * 1000) == "a", "Long."
print("The local tests are done.")
Nov. 18, 2021