Problem 42. Find the alphabetic word product
If the input string s is a word like 'hello', then the output word product p is a number based on the correspondence a=1, b=2, ... z=26. Assume the input will be a single word, although it may mixed case. Note that A=a=1 and B=b=2.
So
s = 'hello'
means
p = 8 * 5 * 12 * 12 * 15 = 86400
Bonus question: How close can you get to a word product of one million?
Solution Stats
Problem Comments
-
9 Comments
For the bonus question (on OSX):
words= textread('/usr/share/dict/words','%s');
for k=1:numel(words)
wordprod(k) = word_product(words{k});
end
[~,i] = min(abs(wordprod-1000000));
words{i}
wordprod(i)
% curing with word product of 1000188
For the bonus question, we can rule out any number that has a prime factor greater than 26 (z). The product found by Jason Friedman is the first number greater than 10^6 that does not have such a prime factor. The product 999856 is the largest number less than 10^6 to be part of a possible solution.
I like playing with strings and ASCII table ;)
Everett appears to miss the fact that 1000000 has no prime factors above 26, and Jason's dictionary doesn't seem to include obsolete words. 'tetty' scores a perfect 1000000.
Well, if you happen to know someone named 'BettyJ', thus a first name of Betty, last initial J, this works: word_product('BettyJ').
Could you send me the answer?
I had benn worked for 1 week but Icouldnt find answer. İf anyone solves Please send answer. Really I need it.
Nice problem
Can you give me a hint on how to program the bonus question? I used factor but that is not a good way.
If we can include multiple words in our bonus answer, the word "tea" 3 times scores perfect. n = 'teateatea'
Solution Comments
Show commentsProblem Recent Solvers3343
Suggested Problems
-
42317 Solvers
-
What is the next step in Conway's Life?
654 Solvers
-
299 Solvers
-
735 Solvers
-
881 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!