Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Most Wanted Letter by LT04
def checkio(text):
x = str.lower(text)
dictionary = {}
e=[]
v=[]
p=[]
for i in x:
if i in dictionary:
dictionary[i] += 1
else:
dictionary[i] = 1
for i in dictionary:
e.append(str(dictionary[i]))
for i in e:
v.append(int(i))
w = sorted(v, reverse = True)
y = sorted(dictionary, key = dictionary.get, reverse=True)
print (w)
print(y)
for i in range(len(w)):
if w[i] == w[0]:
if ord(y[i]) >96 and ord(y[i]) <123:
p.append(y[i])
else:
w[0] = w[i+1]
u = sorted(p)
for i in range(len(u)):
if ord(u[i]) > 96 and ord(u[i]) < 123:
return u[i]
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio ("Lorem ipsum dolor sit amet 0000000000000000000") == "m", "T"
assert checkio ("ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba") == "a", "TTT"
assert checkio ("a-z") == "a", "Teest"
assert checkio("But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.") == "e", "Test"
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.")
Oct. 23, 2017