input=111115
output=5115
how to solve this problem in python?
input=111115
output=5115
how to solve this problem in python?
For further actions, you may consider blocking this person and/or reporting abuse
David Sola -
fast-d3v -
0xkoji -
Bryan Doss -
Top comments (1)
1) Converting the number to a string
2) Using
itertools.groupby
to group each subsequent repeating digit3) Concatenating each grouped digit with the size of its group
4) Concatenating the whole thing to one string
(I interpreted the question so that the expected output for 151 is 111511 and not 2115).