All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Close to a million (Posted on 2005-07-18)
The first 26 primes (2, 3, 5, ...) can be put in correspondence with the letters A through Z, so the common English word CAB would be the product 5 * 2 * 3 = 30. Using this code, what´s your guess to a common English word that comes closest to a million ? I found one very, very close. Can you beat mine ?

To help you, here are the 26 first primes and their correspondence to the alphabet :
``` 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```

 See The Solution Submitted by pcbouhid Rating: 3.4000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer soln -- spoiler | Comment 2 of 12 |

DEFDBL A-Z
DATA 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
DIM prime(26)
FOR i = 1 TO 26: READ prime(i): NEXT
best = 1000000
OPEN "\words\words.txt" FOR INPUT AS #1
DO
LINE INPUT #1, w\$
w2\$ = LCASE\$(w\$)
t = 1
FOR i = 1 TO LEN(w2\$)
t = t * prime(ASC(MID\$(w2\$, i, 1)) - ASC("a") + 1)
NEXT
diff = ABS(1000000 - t)
IF diff < best THEN best = diff: b\$ = w\$: v = t: PRINT b\$, best, v
LOOP UNTIL EOF(1)
CLOSE

finds the best word is colic, with the value 999,925.

 Posted by Charlie on 2005-07-18 04:48:30

 Search: Search body:
Forums (0)