Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. The Academy needs you! We have this list of words and we have to find the heaviest one, but we haven't a clue how to approach the problem.
  2.  
  3. Word heaviness is determined by summing all the letters in it.The letter value corresponds to the position in the English
  4. alphabet - where a is 1 and z is 26. For example, the word alpha has a weight of 1 + 12 + 16 + 8 + 1 = 38.
  5. Treat lower- and uppercase letters the same, so a and A both have the value 1.
  6.  
  7. Your task is to create a program that finds the heaviest word and prints its weight and the word itself to the standart output.
  8.  
  9. Input
  10. On the first line, N - the number of words to follow.
  11. On the next N lines - a single word.
  12. Output
  13. The heaviest weight and the heaviest word, separated by a space.
  14. Constraints
  15. 5 <= N <= 500
  16. 3 <= letters in a word <= 20
  17. Sample tests
  18. Input
  19. 5
  20. telerik
  21. alpha
  22. java
  23. Spring
  24. nodeJS
  25. Output
  26. 83 Spring
  27. Input
  28. 7
  29. gosho
  30. Pesho
  31. staMAT
  32. apostol
  33. spiridon
  34. PAUN
  35. StrAHiL
  36. Output
  37. 104 spiridon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement