Skip to main content
2 of 7
added 76 characters in body
smci
  • 914
  • 5
  • 14

Find the word with the highest product of letter-prime values where A=2, B=3, C=5, ..., Z=101

If each individual letter A..Z of an (English) word gets a value corresponding to the n'th prime (see table below), then which word has the highest product of its letter scores? Normal English words please, not IUPAC chemical names). (I wanted to restrict this to everyday words, but that's not well-defined).

For example:

  • SYZYGIUM = 74511467904889 (7.45e+13)
  • WOODWORKING = 159178548575947607 (1.59e+17)

Letter values A:2 B:3 C:5 D:7 E:11 F:13 G:17 H:19 I:23 J:29 K:31 L:37 M:41 N:43 O:47 P:53 Q:59 R:61 S:67 T:71 U:73 V:79 W:83 X:89 Y:97 Z:101

Some Python starter code:

primes = { letter_prime[0]:letter_prime[1] for letter_prime in zip(string.ascii_uppercase, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101])}
{'A': 2, 'B': 3, 'C': 5, 'D': 7, 'E': 11, 'F': 13, 'G': 17, 'H': 19, 'I': 23, 'J': 29, 'K': 31, 'L': 37, 'M': 41, 'N': 43, 'O': 47, 'P': 53, 'Q': 59, 'R': 61, 'S': 67, 'T': 71, 'U': 73, 'V': 79, 'W': 83, 'X': 89, 'Y': 97, 'Z': 101}

def letter_prime_score(word):
    score = 1
    for letter in word:
        score *= primes[letter]
    return score

letter_prime_score('WOODWORKING')
159178548575947607

'{:.3g}'.format(letter_prime_score('WOODWORKING'))
'1.59e+17'
smci
  • 914
  • 5
  • 14