Guest User

Untitled

a guest
Dec 13th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import string
  2. import time
  3. beginning = time.time()
  4.  
  5. alphabet = string.ascii_uppercase
  6.  
  7. def func_word(n):
  8. t = 0
  9. for i in n:
  10. t += (alphabet.index(i)+1) #Index starts with 0,not 1
  11. return t
  12.  
  13. total = 0
  14. with open("Dosyalar.txt","r") as file:
  15. content = (file.read()).split(",")
  16. content.sort()
  17. for i in content:
  18. result = (func_word(i[1:-1])) * (content.index(i) + 1)
  19. total += result
  20.  
  21. print(total)
  22.  
  23. elapsed = time.time()-beginning
  24. print("elapsed time :",elapsed)
Add Comment
Please, Sign In to add comment