If we value each letter corresponding to its position in the alphabet, we may compute the value of a word as the sum of the values of its individual letters. We can use this procedure to hunt for word sums. A word sum is a sequence of (usually two) words whose sum of word values equals the word value of another word that can be associated with the sequence of words.
KING + CHAIR = THRONE
Checking whether two words are a word sum when combined with a third word is fairly straightforward. However, it is far more difficult to find good word sums, especially since the associations determine their quality. Here we provide you with a couple of examples, where we give the word value of each word between a pair of brackets.
term 1 | term 2 | result |
---|---|---|
ARM (32) | BEND (25) | ELBOW (57) |
WHITE (65) | HOUSE (68) | GOVERNMENT (133) |
MONA (43) | LISA (41) | LEONARDO (84) |
PETER (64) | PAN (31) | NEVERLAND (95) |
FAMILY (66) | TREE (48) | ANCESTORS (114) |
RED (27) | BULL (47) | COCKTAIL (74) |
EGG (19) | PLANT (63) | AUBERGINE (82) |
ANT (35) | LION (50) | DOODLEBUG (85) |
VISUAL (84) | BASIC (34) | MICROSOFT (118) |
BLACK (29) | JACK (25) | VEGAS (54) |
Along the same lines we can also make associations with names of famous people.
term 1 | term 2 | result |
---|---|---|
JOHN (47) | CLEESE (49) | HUMOUR (96) |
TOM (48) | HANKS (53) | FORREST (101) |
BOB (19) | MARLEY (74) | RASTAFARI (93) |
KURT (70) | COBAIN (44) | NOVOSELIC (114) |
NELSON (79) | MANDELA (50) | HUMANITARIAN (129) |
EMMA (32) | WATSON (92) | VOLDEMORT (124) |
JAMES (48) | BOND (35) | DANIEL CRAIG (83) |
GEORGE (57) | LUCAS (56) | JAR JAR BINKS (113) |
STEPHEN (87) | HAWKING (73) | TEXT TO SPEECH (160) |
CLOCKWORK (111) | ORANGE (60) | STANLEY KUBRICK (171) |
With the last four examples in the above table, we only take into account the letters to determine the value of a word. This allowed us to come up with multi-word results.
Write a function letter_value that takes a string (str) containing a single character. The function must return the value (int) of the character. Letters have a value that corresponds to their position in the alphabet (A=1, B=2, C=3, …). No distinction is made between uppercase and lowercase letters. All other characters have a zero value.
Write a function word_value that takes a string (str) argument. The function must return the sum of the values (int) of all characters in the given string.
Write a function is_word_sum that takes three strings (str). The function must return a Boolean value (bool) that indicates whether or not the sum of the word values of the first two arguments equals the word value of the third argument.
>>> letter_value('A')
1
>>> letter_value('j')
10
>>> letter_value('!')
0
>>> word_value('arm')
32
>>> word_value('BEND')
25
>>> word_value('elbow')
57
>>> is_word_sum('arm', 'BEND', 'elbow')
True
>>> is_word_sum('KING', 'chair', 'THRONE')
True
>>> is_word_sum('Monty', 'Python', 'SHRUBBERY')
False