Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
O(n) solution in Speedy category for The Most Wanted Letter by Sim0000
def checkio(text):
count = {}
minc = None
for c in text.lower():
if not c.isalpha(): continue
count[c] = count.get(c, 0) + 1
if minc == None or count[c] > count[minc] or (count[c] == count[minc] and c < minc):
minc = c
return minc
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
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."
Jan. 24, 2018