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

Home > General
Morse Code Puzzle (Posted on 2005-10-27) Difficulty: 3 of 5
A list of fruits and vegetables has been written in Morse Code and all the spaces between the letters have been removed. What are the fruits and vegetables in the list?
 1: ***-*-**-*---*****-**-*-*--
 2: *--*----*-----
 3: -*-**--*-*-*-**---**-*--**
 4: *-**--***********
 5: *-*******--****-*-*-***
 6: ---*-**--*--**
 7: *-***------*
 8: -*-***-****-*-*--
 9: *-***--**--*-**
10: --*--*--*---
Morse Code Alphabet:
 A: *-    B: -***  C: -*-*  D: -**   E: *     F: **-*
 G: --*   H: ****  I: **    J: *---  K: -*-   L: *-**
 M: --    N: -*    O: ---   P: *--*  Q: --*-  R: *-*
 S: ***   T: -     U: **-   V: ***-  W: *--   X: -**-
 Y: -*--  Z: --**

See The Solution Submitted by Brian Smith    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 4 of 5 |

Not having a separate word list for veggies, the following list had to be winnowed to separate the wheat from the chaff:

1 strawberry

2 potato

3 cantaloupe

4 radish

5 rhubarb

6 orange

7 lemon rewon

8 celery citify

9 lanated legated lettuce reemitted repand

10 mango typo

DECLARE SUB trans (cy$)
DECLARE FUNCTION isWord! (w$)
DATA ***-*-**-*---*****-**-*-*--
DATA *--*----*-----
DATA -*-**--*-*-*-**---**-*--**
DATA *-**--***********
DATA *-*******--****-*-*-***
DATA ---*-**--*--**
DATA *-***------*
DATA -*-***-****-*-*--
DATA *-***--**--*-**
DATA --*--*--*---
DATA "A: *-   B: -***  C: -*-*  D: -**   E: *     F: **-* "
DATA "G: --*  H: ****  I: **    J: *---  K: -*-   L: *-** "
DATA "M: --   N: -*    O: ---   P: *--*  Q: --*-  R: *-* "
DATA "S: ***  T: -     U: **-   V: ***-  W: *--   X: -**- "
DATA "Y: -*-- Z: --** "

DIM SHARED ltr$(26), alp$, t$
alp$ = "abcdefghijklmnopqrstuvwxyz"

FOR i = 1 TO 10
 READ cyph$(i)
 PRINT cyph$(i)
NEXT i

l = 0
FOR i = 1 TO 5
 READ s$
 DO

  ix = INSTR(s$, ":")
  IF ix THEN
  s$ = LTRIM$(MID$(s$, ix + 1))
  ix2 = INSTR(s$, " ")
  IF ix2 THEN
  l = l + 1
  ltr$(l) = LEFT$(s$, ix2 - 1)
  s$ = LTRIM$(MID$(s$, ix2))
  PRINT l, ltr$(l)
  END IF
  END IF
 LOOP UNTIL ix = 0
NEXT

FOR w = 2 TO 10
 PRINT w;
 trans cyph$(w)
 PRINT : PRINT
NEXT

FUNCTION isWord (w$)
 n = LEN(w$)
 w1$ = SPACE$(n)
 OPEN "words" + LTRIM$(STR$(n)) + ".txt" FOR BINARY AS #2
 l = LOF(2) / n
 low = 1: high = l
 DO
  mid = INT((low + high) / 2)
  GET #2, (mid - 1) * n + 1, w1$
  IF w1$ = w$ THEN isWord = 1: CLOSE 2: EXIT FUNCTION
  IF w1$ < w$ THEN low = mid + 1:  ELSE high = mid - 1
 LOOP UNTIL low > high
 isWord = 0
 CLOSE 2
END FUNCTION

SUB trans (cy$)
 c$ = cy$
 FOR l = 1 TO 26
 cl$ = ltr$(l)
 IF LEN(c$) >= LEN(cl$) THEN
  IF LEFT$(c$, LEN(cl$)) = cl$ THEN
  
  c$ = MID$(c$, LEN(cl$) + 1)
  t$ = t$ + MID$(alp$, l, 1)
  
  IF LEN(t$) < 20 THEN
   IF c$ = "" THEN
    IF isWord(t$) THEN
    PRINT t$; " ";
    END IF
   ELSE
    trans c$
   END IF
  END IF
  
  t$ = LEFT$(t$, LEN(t$) - 1)
  c$ = cl$ + c$
  
  END IF' left(c$) matches cl$
 END IF' len(c$)
 NEXT l
END SUB

 


  Posted by Charlie on 2005-10-27 16:06:14
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 (10)
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