In this word game points are awarded based on the length of the word and the letters used. The user has to create a word from the letters in their hand. Their hand consists of 7 letters.
Could you create a function which returns the correct scores for the words played? The input is a list of words, and the output is an object where the keys are the words played and the values are the word points.
The score of the word is the sum of the points of all the letters multiplied by the number of letters in the word. If they use all 7 of their letters then they get a 50-point bonus.
The letter points are:
"a" : 1,
"b" : 3,
"c" : 3,
"d" : 2,
"e" : 1,
"f" : 4,
"g" : 2,
"h" : 4,
"i" : 1,
"j" : 8,
"k" : 5,
"l" : 1,
"m" : 3,
"n" : 1,
"o" : 1,
"p" : 3,
"q" : 10,
"r" : 1,
"s" : 1,
"t" : 1,
"u" : 1,
"v" : 4,
"w" : 4,
"x" : 8,
"y" : 4,
"z" : 10
Examples:
- The word 'great' gives a score of 30. The sum of the letter values is 6 (g=2, r=1, e=1, a=1, t=1) and it is a 5-letter word, and 6*5=30.
- The word 'jukebox' gives a score of 239. The sum of the letter values is 27 (j=8, u=1, k=5, e=1, b=3, o=1, x=8) and it is a 7-letter word therefore it gets the 50-point bonus, and 27*7+50=239.
Example input:
["great", "jukebox"]
Example output:
{
great: 30,
jukebox: 244
}