9
$\begingroup$

An old and popular puzzle, recently revived on Twitter by Alex Bellos, Chris Smith, and others, asks to take the first 26 primes, relate each to letters of the alphabet (A = 2, B = 3, C = 5, ..., Y = 97, Z = 101), and use this code to find the (legitimate) English word that comes closest to a million, where the word's numeric value is given by the product of its letters. CAB is thus valued 5x2x3=30.

With the same code, what is the longest English word valued at most a million?

$\endgroup$
  • 3
    $\begingroup$ Well, an upper bound is $19$ letters as $2^{19} = 524288$. $\endgroup$ – Jens Nov 10 at 2:30
  • 1
    $\begingroup$ might be useful: answers.com/Q/… $\endgroup$ – JMP Nov 10 at 3:04
  • 1
    $\begingroup$ What counts as an English word, exactly? $\endgroup$ – Deusovi Nov 10 at 3:06
  • 2
    $\begingroup$ @Deusovi Say a word admissible to Scrabble players. $\endgroup$ – Bernardo Recamán Santos Nov 10 at 3:09
  • 1
    $\begingroup$ Vaguely similar to this one I asked $\endgroup$ – smci Nov 11 at 6:29
13
$\begingroup$

Closest to one million:

COLIC = 999925

This is the sixth-largest number less than or equal to one million with no prime factors greater than 101.

As for longer words:

Without much effort, I have found several seven-letter words with values less than one million. In particular, the least among them is CABBAGE = 33660. I expect their is some eight-letter word to be found.

$\endgroup$
  • $\begingroup$ I came to the same result. $\endgroup$ – Alexander Geldhof Nov 10 at 18:53
6
$\begingroup$

Using the scrabble dictionary, and a short python program:

Several 8-letter words, I think the best one is
CABBAGED: 235620 "To steal, pilfer"
But the 8-letter one closest to 1,000,000 is:
ANABAENA: 976272 "A genus of filamentous cyanobacteria that exist as plankton"
Other 8-letter words: cabbalah: 253080, cabbalas: 892440, dahabeah: 667128.

$\endgroup$
  • 1
    $\begingroup$ Note that 'closest to one million' and 'longest not more than one million' were two separate queries $\endgroup$ – Daniel Mathias Nov 10 at 4:25
  • $\begingroup$ @Daniel Mathias Ah, the "closest to one million" means of the 8-letter words. Edited answer for clarity. $\endgroup$ – IronEagle Nov 10 at 4:28
  • $\begingroup$ Can you please share the Python code? $\endgroup$ – Zacky Nov 11 at 0:27
  • $\begingroup$ Uhr... I thought the solution was the old smiles joke, with two s's removed... $\endgroup$ – WhatsUp Nov 11 at 1:03
  • $\begingroup$ @Nyssa Essentially the same as CDJB's answer. $\endgroup$ – IronEagle Nov 11 at 19:15
4
$\begingroup$

I used an english wordlist from here, and a short python program to yield:

Longest possible word under 10**6:

calabaza (8 characters) - 896880

Closest to 10**6:

colic - 999925

Code used:

import numpy as np
SCORER = {'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 load_words():
    with open('words_alpha.txt') as word_file:
        valid_words = set(word_file.read().split())
    return valid_words

def getScore(word):
    return np.prod([SCORER[char] for char in word], dtype=np.uint64)

english_words = load_words()

longest = ''
closest = ('', 0)

for word in english_words:
    score = getScore(word)
    if score < 10**6:
        if len(word) > len(longest):
            longest = word
        if 10**6 - closest[1] > 10**6 - score:
            closest = (word, score)

print(longest, getScore(longest))
print(closest)
$\endgroup$
3
$\begingroup$

To get the ball rolling, I've got

CABBAGE
Length: 7
Value: 33,660

$\endgroup$
3
$\begingroup$

Note: this does not answer the question asked; it answers the question of finding the best possible value at most a million, not the longest length.

Here's a Mathematica notebook (via Wolfram Programming Lab) that I used to check for better solutions: https://www.wolframcloud.com/obj/solly.ucko/Published/Longest_word_worth_at_most_a_million.nb

In[1]:= letterMapping = AssociationThread[Prime[Range[26]], Alphabet[ ]]
Out[1]= <|2 → a, 3 → b, 5 → c, 7 → d, 11 → e, 13 → f, 17 → g, 19 → h,
23 → i, 29 → j, 31 → k, 37 → l, 41 → m, 43 → n, 47 → o, 53 → p, 59 → q,
61 → r, 67 → s, 71 → t, 73 → u, 79 → v, 83 → w, 89 → x, 97 → y, 101 → z|>
In[2]:= factorList[n_] := Flatten[Map[Apply[ConstantArray], FactorInteger[n], 1]]
In[3]:= f[n_] := Map[letterMapping, factorList[n]]
In[4]:= factorList[1 000 000]
Out[4]= {2, 2, 2, 2, 2, 2, 5, 5, 5, 5, 5, 5}
In[5]:= Select[Table[f[n], {n, 1 000 000, 1 000 000 - 75, -1}], Not@* AnyTrue[MissingQ]]
Out[5]= { {a, a, a, a, a, a, c, c, c, c, c, c}, {b, b, b, d, e, f, l},
{f, f, r, y}, {j, j, j, m}, {a, a, a, a, a, a, a, a, a, b, b, d, k}, {c, c, i, l, o} }

So unless a permutation of {a, a, a, a, a, a, c, c, c, c, c, c}, {b, b, b, d, e, f, l}, {f, f, r, y}, {j, j, j, m}, or {a, a, a, a, a, a, a, a, a, b, b, d, k} is a valid word (unlikely), Daniel Mathias's answer of

COLIC

is optimal.

$\endgroup$
  • $\begingroup$ @JiK Oh, oops... I'll work on fixing it at some point if/when I get a chance. $\endgroup$ – Solomon Ucko Nov 11 at 14:10
1
$\begingroup$

I wrote a program to check a list of words from

https://www.wordgamedictionary.com/twl06/download/twl06.txt .

In addition to

ANABAENA,

which others have found, here are the words of each length with the lowest scores:

A (2) AA (4) ABA or BAA (12) ABBA or BABA (36) ABACA (120) BACCAE (3 300) CABBALA (13 320) CABBAGED (235 620) ABDICABLE (11 794 860) DEADHEADED (242 875 556) ABRACADABRA (37 507 680) ABRACADABRAS (2 513 014 560)

No words over 12 letters long are listed, possibly at least in part because a Scrabble board is 15x15.

Interestingly, there is an 11-length word with a lower score than any 10-length word.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.