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

Home > Logic
Ady's RH problem (Posted on 2014-03-11) Difficulty: 4 of 5
Let

Sequence1= (all existing 4-digit numbers, no leading zeros);
Sequence2= (each member of seq1 replaced by 1 iff fulfilling both conditions : cond1 and cond2; replaced by 0 otherwise.)

Cond1: k (the number of letters in the English set of words representing N) is even.
For example the number 3024 (three thousand twenty four) does not qualify (23 letters) .

Cond2: the number N is evenly divisible by 3, e.g. the number 3024 qualifies.

Ergo: 3024 of Sequence1 will be replaced by 0 in Sequence2.

Denote by N1 the number of ones in the seq2 and by N0 the number of zeroes in that sequence.

Don't be intimidated by the D4 label,- reread the text carefully and try to answer all of the following questions:

a. What does the RH stand for?
b. Is it true that abs(N1- N0) is an even number?
c. What is the meaning of KISS?
d. Why D4?

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
for the curious on the question not asked | Comment 3 of 6 |

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 = 1000 TO 9999
          ' IF n / 10 = INT(n / 10) 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
          IF LEN(name$) MOD 2 = 0 AND n MOD 3 = 0 THEN onect = onect + 1:  ELSE zeroct = zeroct + 1
        '  PRINT "  "; name$
        NEXT

     PRINT onect, zeroct

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

finds there are 1500 1's and 7500 0's in sequence 2.


  Posted by Charlie on 2014-03-11 17:01:47
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 (13)
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