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

Home > General > Word Problems
Make the proof full-proof (Posted on 2017-07-11) Difficulty: 3 of 5
Every number greater than M has at least N letters in common with each of its neighbors.

Insert the correct values for M & N and show why it works.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution first the computer,then a human correction Comment 1 of 1
According to the program below, testing numbers up to 2 million:

Every number greater than 7 has at least 1 letter in common with each of its neighbors.

Every number greater than 12 has at least 2 letters in common with each of its neighbors.

Every number greater than 100 has at least 4 letters in common with each of its neighbors.

Every number greater than 1,000,000 has at least 6 letters in common with each of its neighbors.

But is that true beyond 2 million? It's based on a program that goes up to only 2 million. What about the center number (2) in this triplet:

1. nine-million nine hundred ninety-nine thousand, nine hundred ninety-nine

2. one billion

3. one billion one

Only O, N, E, I, L and B are shared by the latter two, but B is not present in the first of the three. We must change the set of solutions to 

Every number greater than 7 has at least 1 letter in common with each of its neighbors.

Every number greater than 12 has at least 2 letters in common with each of its neighbors.

Every number greater than 100 has at least 4 letters in common with each of its neighbors.

Every number greater than 1,000,000 has at least 5 letters in common with each of its neighbors.



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$
'DO
CLS
FOR n = 1 TO 2000000

    pp$ = p$
    p$ = name$

    IF n / 10000 = INT(n / 10000) THEN PRINT n;
    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
    name$ = UCASE$(name$)
    '   PRINT name$;
    DO
        i = verify(name$, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
        IF i THEN name$ = LEFT$(name$, i - 1) + MID$(name$, i + 1)
    LOOP UNTIL i = 0
    '  PRINT "  "; name$

    lmtch = LEN(linc$(linc$(pp$, p$), name$))
    FOR i = lmtch + 1 TO 10
        lastLT(i) = n - 1
    NEXT

NEXT
FOR i = 1 TO 10
    PRINT i, lastLT(i)
NEXT
'LOOP

SUB EnterNum
DO
    INPUT "Enter number:", num$
    num$ = LTRIM$(RTRIM$(num$))
    num = 1
    FOR i = 1 TO LEN(num$)
        IF INSTR("0123456789", MID$(num$, i, 1)) = 0 THEN num = 0: EXIT FOR
    NEXT
    IF num = 0 THEN PRINT "Must be numeric."
LOOP WHILE num = 0
END SUB

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

FUNCTION linc$ (a$, b$)
ls$ = ""
FOR i = 1 TO LEN(a$)
    c$ = MID$(a$, i, 1)
    IF INSTR(a$, c$) = i AND c$ <> " " AND c$ <> "-" THEN
        IF INSTR(b$, c$) > 0 THEN ls$ = ls$ + c$
    END IF
NEXT
linc$ = ls$
END FUNCTION


  Posted by Charlie on 2017-07-11 10:48:27
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 (4)
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