Advertisement
Guest User

Untitled

a guest
Jun 29th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4. # Auto-generated code below aims at helping you parse
  5. # the standard input according to the problem statement.
  6.  
  7. m = [c for c in input().upper() if c.isalpha()]
  8. for a,b in zip(m,m[1:]):
  9. if a!=b:
  10. d=b>a
  11. break
  12. r=[]
  13. for a,b in zip(m,m[1:]):
  14. if b>a:
  15. r+=1,
  16. elif b<a:
  17. r+=0,
  18. else:
  19. r+=r[-1] if r else d,
  20. r = [r[0]]+r
  21. from itertools import*
  22. res=[]
  23. for k,v in groupby(r):
  24. l=len([*v])
  25. res+=str(l),
  26. print(*res,sep='-')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement