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

Home > General > Word Problems
High and low (Posted on 2018-05-21) Difficulty: 2 of 5
Using any letter not more than once, what are the largest and smallest numbers
that may be writen down in words?

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 3 |
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
OPEN "highnlow.txt" FOR OUTPUT AS #2
FOR n = 1 TO 10000
    
        num$ = LTRIM$(STR$(n))
        num = 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
        name$ = LTRIM$(RTRIM$(name$))
        good = 1: goodneg = 1
        FOR i = 1 TO LEN(name$)
            IF INSTR(name$, MID$(name$, i, 1)) < i THEN
              good = 0: EXIT FOR
            END IF
            IF INSTR("minus", MID$(name$, i, 1)) > 0 THEN goodneg = 0
        NEXT
        IF good THEN
          PRINT name$; : PRINT #2, name$;
          IF goodneg THEN PRINT " **"; : PRINT #2, " **";
          PRINT : PRINT #2,
        END IF
        a$ = INKEY$: IF a$ = CHR$(27) THEN PRINT n

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

Finds the following numbers that satisfy the criterion:

one
two **
four
five
six
eight
ten
forty **
forty-six
sixty
sixty-one
sixty-four
eighty
eighty-four
five thousand

Those marked with a double asterisk serve also as negative when preceded by "minus". The smallest and largest are therefore minus forty and five thousand.

  Posted by Charlie on 2018-05-21 10:35:42
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 (23)
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