A self-fulfiller (also called autological word) is a word or an expression that expresses a property that it also possesses. For example, the word short is short, noun is a noun, English is English, pentasyllabic has five syllables, word is a word, and sesquipedalian is a long word. The word or expression thus speaks for itself because it self-references one of its own properties.
In 2011 Dave Morice observed that the word LUCK requires 7 penstrokes, BLACKJACK requires 21 penstrokes, FREEZING POINT requires 32 penstrokes and HOURS IN A DAY requires 24 penstrokes. But there are other possibilities to assign integer values to each letter in the alphabet that give a special or literal meaning to particular words or expressions. We list a few examples.
TEN is spelled with ten raised dots in Braille.
FIFTEEN is spelled with 15 dots and dashes in International Morse Code.
TWELVE is worth 12 points in Scrabble.
Write a function lettervalue that takes a list or tuple containing 26 integers. Each integer corresponds to the letter at the same position in the alphabet. The function must return a dictionary that maps each uppercase letter in the alphabet to its corresponding integer value in the given list or tuple.
Use the function lettervalue to write a function wordvalue that takes two arguments: a string and a list or tuple containing 26 integers. The second argument has the same meaning as the argument passed to the function lettervalue. The function must return the integer that results as the sum of the values of the individual letters in the given string. In computing this sum, the function must treat the given string in a case insensitive way and ignore all characters that are not letters.
>>> penstrokes = [3, 3, 1, 2, 4, 3, 2, 3, 1, 2, 3, 2, 4, 3, 1, 2, 2, 3, 1, 2, 1, 2, 4, 2, 3, 3]
>>> value = lettervalue(penstrokes)
>>> value['L']
2
>>> value['U']
1
>>> value['C']
1
>>> value['K']
3
>>> wordvalue('LUCK', penstrokes)
7
>>> wordvalue('blackjack', penstrokes)
21
>>> wordvalue('FREEZING POINT', penstrokes)
32
>>> wordvalue('Hours in a Day', penstrokes)
24
>>> wordvalue('Twenty-nine', penstrokes)
29
>>> braille = (1, 2, 2, 3, 2, 3, 4, 3, 2, 3, 2, 3, 3, 4, 3, 4, 5, 4, 3, 4, 3, 4, 4, 4, 5, 4)
>>> wordvalue('TEN', braille)
10
>>> wordvalue('ten + ten', braille)
20
>>> morse = [2, 4, 4, 3, 1, 4, 3, 4, 2, 4, 3, 4, 2, 2, 3, 4, 4, 3, 3, 1, 3, 4, 3, 4, 4, 4]
>>> wordvalue('fifteen', morse)
15
>>> wordvalue('Se7en', morse)
7
>>> scrabble = (1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10)
>>> wordvalue('TWELVE', scrabble)
12
>>> wordvalue('Life, Universe and Everything', scrabble)
42