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

Home > General
Close to a million (Posted on 2005-07-18) Difficulty: 1 of 5
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.)
Solution 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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information