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

Home > General > Word Problems
Math spelling (Posted on 2013-03-04) Difficulty: 2 of 5
What is the smallest number whose English name contains all five vowels, each one exactly once?

See The Solution Submitted by Ady TZIDON    
Rating: 5.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solutions | Comment 2 of 9 |

Modifying a program used previously in other contexts:

DECLARE FUNCTION verify! (s1$, s2$)
DECLARE SUB EnterNum ()
DECLARE SUB ProcPiece (piece$, MajorPower!)
DATA one,two,three,four,five,six,seven,eight,nine
DATA ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen
DATA eighteen,nineteen
DATA twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety
DATA thousand,million,billion,trillion,quadrillion,quintillion,sextillion
DIM SHARED unit$(19), ten$(10), major$(7)
FOR i = 1 TO 19
  READ unit$(i)
NEXT
FOR i = 2 TO 9
  READ ten$(i)
NEXT
FOR i = 1 TO 7
  READ major$(i)
NEXT
DIM SHARED name$, num$
        CLS
        FOR n = 1 TO 50000
          num$ = LTRIM$(RTRIM$(STR$(n)))

          IF num$ = "0" THEN
                  name$ = "zero"
          ELSE
                  name$ = ""
                  MajorPower = 0
                  DO
                          l = LEN(num$): IF l > 3 THEN l = 3
                          piece$ = RIGHT$(num$, l)
                          num$ = LEFT$(num$, LEN(num$) - l)
                          CALL ProcPiece(piece$, MajorPower)
                          MajorPower = MajorPower + 1
                  LOOP WHILE LEN(num$) > 0
          END IF
          nsave$ = name$
          name$ = UCASE$(name$)
          DO
            i = verify(name$, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
            IF i THEN name$ = LEFT$(name$, i - 1) + MID$(name$, i + 1)
          LOOP UNTIL i = 0
          act = 0: ect = 0: ict = 0: oct = 0: uct = 0
          FOR i = 1 TO LEN(name$)
            SELECT CASE MID$(name$, i, 1)
             CASE "A"
               act = act + 1:
             CASE "E"
               ect = ect + 1
             CASE "I"
               ict = ict + 1
             CASE "O"
               oct = oct + 1
             CASE "U"
               uct = uct + 1
            END SELECT
          NEXT
          IF act = 1 AND ect = 1 AND ict = 1 AND oct = 1 AND uct = 1 THEN PRINT n, nsave$
        NEXT

SUB ProcPiece (piece$, MajorPower)
  piece = VAL(piece$)
  n$ = ""
  IF piece > 99 THEN
    n$ = unit$(piece \ 100) + " hundred "
    piece = piece MOD 100
  END IF
  IF piece > 19 THEN
    n$ = n$ + ten$(piece \ 10)
    piece = piece MOD 10
    IF piece > 0 THEN n$ = n$ + "-":  ELSE n$ = n$ + " "
  END IF
  IF piece > 0 THEN n$ = n$ + unit$(piece) + " "
  IF n$ > "" THEN name$ = n$ + major$(MajorPower) + " " + name$
END SUB

FUNCTION verify (s1$, s2$)
  FOR i = 1 TO LEN(s1$)
    IF INSTR(s2$, MID$(s1$, i, 1)) = 0 THEN verify = i: EXIT FUNCTION
  NEXT
  verify = 0
END FUNCTION

 

5000         five thousand
6010         six thousand ten
6020         six thousand twenty (first if Y were required)
8000         eight thousand
9000         nine thousand
10006        ten thousand six
10030        ten thousand thirty
10050        ten thousand fifty
10060        ten thousand sixty
20006        twenty thousand six
20030        twenty thousand thirty (among others, doesn't count when using Y's, as it has two)
20050        twenty thousand fifty
20060        twenty thousand sixty
26000        twenty-six thousand
30010        thirty thousand ten
30020        thirty thousand twenty

If, as many do, one uses "and" to separate hundreds or thousands from lower positions:

206          TWOHUNDRED and SIX
230          TWOHUNDRED and THIRTY
250          TWOHUNDRED and FIFTY
260          TWOHUNDRED and SIXTY
602          SIXHUNDRED and TWO
640          SIXHUNDRED and FORTY

(the "and" list obtained by changing

          IF act = 1 AND ect = 1 AND ict = 1 AND oct = 1 AND uct = 1 THEN PRINT n, nsave$
       

to

          IF act = 0 AND ect = 1 AND ict = 1 AND oct = 1 AND uct = 1 THEN PRINT n, nsave$
       

and inserting "and"s manually.)


  Posted by Charlie on 2013-03-04 12:11:03
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 (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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