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

Home > Just Math
D is harder than C (Posted on 2013-03-29) Difficulty: 4 of 5
YES, DECODING is harder than CODING.
Let's assign integer numbers to letters according to their place in the English ABC (a=1, b=2,...,z=26.)

We then "code" a given word by 2 parameters, e.g:
YES SIR⇒(49,2375)(46,3078)
NO WAY⇒(29,210)(49,575)

Once you find how the coding was done, you will understand that
a) There is no one-to-one-correspondence between the word
and the ordered couple, so STAR, ARTS and RATS produce identical couples.
b) The correct decoding of a meaningful phrase might be possible.

NOW DECODE THE FOLLOWING PHRASES
(only one 5-letter word - all other words less than that):
a. (26,100)(39,1620)(58,6900)
b. (49,2375)(28,115)(18,42)
c. (46,2760)(19,60)(61,7875)(19,60)
d. (52,3680)(18,65)(99,2794500)


See The Solution Submitted by Ady TZIDON    
Rating: 4.6667 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer assisted solution | Comment 2 of 11 |
ABCDEFGHIJKLMNOPQRSTUVWXYZ
         11111111112222222
12345678901234567890123456

The following program finds all the ways of factoring the second number of a pair with at most five factors of at most 26, that add up to the first number of the pair. It then seeks valid words from anagramming the corresponding letters.

DECLARE SUB factorIt (sb#)
DEFDBL A-Z
CLEAR , , 25000
DIM SHARED sum, prod, remains, fact(5), tot
DO
  INPUT sum, prod
  remains = prod: tot = 0
  factorIt 1
LOOP

SUB factorIt (sb)
  IF sb = 1 THEN ff = 1:  ELSE ff = fact(sb - 1)
  FOR factor = ff TO 26
    IF factor > remains OR factor > sum - tot THEN EXIT FOR
    IF remains MOD factor = 0 THEN
      fact(sb) = factor
      tot = tot + factor
      remains = remains / factor
     
      IF remains = 1 AND sum = tot THEN
         s$ = ""
         FOR i = 1 TO sb
           s$ = s$ + MID$("abcdefghijklmnopqrstuvwxyz", fact(i), 1)
           PRINT fact(i);
         NEXT i
         PRINT
         OPEN "\words\words" + LTRIM$(STR$(sb)) + ".txt" FOR BINARY AS #10
         w$ = SPACE$(sb)
         DO
           GET #10, , w$
           IF EOF(10) THEN EXIT DO
           t$ = w$
           good = 1
           FOR i = 1 TO sb
             ix = INSTR(t$, MID$(s$, i, 1))
             IF ix = 0 THEN good = 0: EXIT FOR
             t$ = LEFT$(t$, ix - 1) + MID$(t$, ix + 1)
           NEXT
           IF good THEN PRINT w$
         LOOP
         CLOSE 10
      END IF
      IF sb < 5 THEN
         factorIt sb + 1
      END IF
     
      tot = tot - factor
      remains = remains * factor
    END IF
  NEXT factor
END SUB

The program's response to a given (sum, product) pair consists of the possible factorings of the product in accordance with the requirements mentioned above. Each factoring is on a separate line and if the letters represented by those factors can be anagrammed into words, they follow on separate lines.
  
? 26,100
 1  5  20
ate
eat
eta
tae
tea

? 39,1620
 1  1  9  10  18
 1  2  3  15  18
carbo
carob
cobra
 1  9  9  20
 6  15  18
for
fro

? 58,6900
 15  20  23
tow
two
wot

EAT FOR TWO or
TEA FOR TWO

 

? 49,2375
 5  19  25
yes

? 28,115
 5  23
we

? 18,42
 1  3  14
can

YES WE CAN

 

? 46,2760
 1  10  12  23
 8  15  23
how
who

? 19,60
 1  1  1  6  10
 1  1  5  12
alae
 2  2  15
bob
 4  15
do
od

? 61,7875
 15  21  25
you

? 19,60
 1  1  1  6  10
 1  1  5  12
alae
 2  2  15
bob
 4  15
do
od

HOW DO YOU DO?

 

? 52,3680
 1  8  20  23
thaw
what

? 18,65
 5  13
em
me

? 99,2794500
 15  18  18  23  25
worry

WHAT, ME WORRY?


  Posted by Charlie on 2013-03-29 17:13:53
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