File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from collections import Counter
2+ def checkio (text : str ) -> str :
3+ a = list (filter (nonum , text ))
4+ b = []
5+ for i in a :
6+ b .append (i .lower ())
7+ x = sorted (Counter (b ).most_common (), key = lambda x : x [1 ], reverse = True )
8+
9+ def p (n ):
10+ if n [1 ] < x [0 ][1 ]:
11+ return False
12+ else :
13+ return True
14+
15+ return sorted (list (filter (p , x )), key = lambda x : x [0 ])[0 ][0 ]
16+
17+
18+ def nonum (n ):
19+ if n .isdigit ():
20+ return False
21+ if ord (n ) < 65 or 90 < ord (n ) < 97 or ord (n ) > 122 :
22+ return False
23+ else :
24+ return True
25+
26+
27+ if __name__ == '__main__' :
28+ print ("Example:" )
29+ print (checkio ("Hello World!" ))
30+
31+ # These "asserts" using only for self-checking and not necessary for auto-testing
32+ assert checkio ("Hello World!" ) == "l" , "Hello test"
33+ assert checkio ("How do you do?" ) == "o" , "O is most wanted"
34+ assert checkio ("One" ) == "e" , "All letter only once."
35+ assert checkio ("Oops!" ) == "o" , "Don't forget about lower case."
36+ assert checkio ("AAaooo!!!!" ) == "a" , "Only letters."
37+ assert checkio ("abe" ) == "a" , "The First."
38+ print ("Start the long test" )
39+ assert checkio ("a" * 9000 + "b" * 1000 ) == "a" , "Long."
40+ print ("The local tests are done." )
You can’t perform that action at this time.
0 commit comments