| about | help | code help+videos | done | prefs |
scrabble2
Given a string, return its English Scrabble score. The Scrabble score is the sum of the Scrabble values of the string's letters (https://en.wikipedia.org/wiki/Scrabble_letter_distributions#English). You can use the following dictionary for the Scrabble values of letters:
value = {'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' : 2, 'q' : 10, 'r' : 1,
's' : 1, 't' : 1, 'u' : 1, 'v' : 4, 'w' : 4, 'x' : 8,
'y' : 4, 'z' : 10}
Strings may now also contain uppercase letters and other symbols.
Use the lowercase letter's value for uppercase letters.
Exclamation marks (!) have a value of 1. Ignore any other symbols.scrabble2('Hello World') → 17 scrabble2('Hello World!') → 18 scrabble2('CodingBat is cool.') → 23 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy