Advertisement
jbn6972

Untitled

Oct 11th, 2022
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #Code Written by : John Nixon
  2. #Date: 11:10:2022  Time: 13:08:18
  3. #Copyrights are applicable
  4. import sys
  5. import os
  6. sys.setrecursionlimit(10000)
  7. try:
  8.     sys.stdin = open('./input.txt', 'r')
  9.     sys.stdout = open('./output.txt', 'w')
  10. except:
  11.     pass
  12.  
  13. given_str = input()
  14.  
  15. words = given_str.split()
  16. ans = ""
  17. for word in words:
  18.     cnt = 0
  19.     prev_char = word[0]
  20.     for char in word[1:]:
  21.         if prev_char < char:
  22.             cnt += 1
  23.         prev_char = char
  24.     ans += str(cnt)
  25.    
  26. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement