#K38442. Highest Scoring Word
Highest Scoring Word
Highest Scoring Word
Given a list of words separated by spaces, each word's score is calculated by summing the positions of its letters in the alphabet (i.e., \(a=1, b=2, \ldots, z=26\)). The task is to output the word with the highest score. In the event of a tie, choose the word that appears first in the input.
Example:
Input: cat dog zebra Output: zebra
Explaination: The score for "cat" is \(3+1+20 = 24\), for "dog" is \(4+15+7 = 26\), and for "zebra" is \(26+5+2+18+1 = 52\). Thus, "zebra" has the highest score.
inputFormat
The input consists of a single line containing several words separated by spaces.
For example:
cat dog zebra
outputFormat
Output the word with the highest score to standard output.
For the sample input above, the output should be:
zebra## sample
cat dog zebra
zebra