Last active
October 7, 2016 20:21
-
-
Save tosho/d54cbfba86cb39e9759a54017018512a to your computer and use it in GitHub Desktop.
Strings and Numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = r"bbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjja" | |
#s = "bbbcccddddeeeee*****f####fffffggggggghhhhhhhhii!!!!!!iiiiiiijjjjjjjjjja" | |
answer = "1122233334444455555566666667777777788888888899999999990" | |
def strings_and_numbers(s): | |
s = list(s) | |
result = s | |
for i in reversed(range(10)): | |
my_dict = {i: s.count(i) for i in s} | |
biggest = (max(my_dict)) | |
for n, j in enumerate(s): | |
if j == biggest: | |
s[n] = i | |
i -= 1 | |
myanswer = ''.join(str(e) for e in result) | |
print(myanswer) | |
strings_and_numbers(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment