Skip to content

Instantly share code, notes, and snippets.

@tosho
Last active October 7, 2016 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tosho/d54cbfba86cb39e9759a54017018512a to your computer and use it in GitHub Desktop.
Save tosho/d54cbfba86cb39e9759a54017018512a to your computer and use it in GitHub Desktop.
Strings and Numbers
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