sibinasto

2. Character Multiplier

Mar 11th, 2021
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. strings = input().split()
  2.  
  3. sums = 0
  4.  
  5. smallest = strings[0]
  6. longest = strings[1]
  7.  
  8. if len(strings[1]) < len(strings[0]):
  9.     smallest = strings[1]
  10.     longest = strings[0]
  11.  
  12. diff = len(longest) - len(smallest)
  13.  
  14. for char in range(len(smallest)):
  15.     sums += ord(smallest[char]) * ord(longest[char])
  16.  
  17. if not diff == 0:
  18.     longest = longest[-diff:]
  19.  
  20.     for el in range(len(longest)):
  21.         sums += ord(longest[el])
  22.  
  23. print(sums)
Advertisement
Add Comment
Please, Sign In to add comment