Advertisement
horozov86

Character Multiplier

Mar 20th, 2023
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. words = input().split()
  2. first_word = words[0]
  3. second_word = words[1]
  4.  
  5. min_len = min(len(first_word), len(second_word))
  6.  
  7. result = 0
  8. for i in range(min_len):
  9.     first_word_char = first_word[i]
  10.     second_word_char = second_word[i]
  11.     result += ord(first_word_char) * ord(second_word_char)
  12.  
  13. for i in range(min_len, len(first_word)):
  14.     result += ord(first_word[i])
  15.  
  16. for i in range(min_len, len(second_word)):
  17.     result += ord(second_word[i])
  18.  
  19. print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement