Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / Help for programming this riddle?

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Help for programming this riddle?
#1136
Posted by: 2003-12-18 22:38:03
Hi!
(Richedit)
Line1:   1
Line2:   11
Line3:   21
Line4:   1211
Line5:   111221
...           ...
line8:   1113213211
...           ...

Do you know this riddle? I want to make a program to show the whole solution for this puzzle by using a richedit. Can you tell me how I can read out one line in a richedit and count how many (the same!!!) numbers stand together?

If you can tell me what the next line should be, you understand the riddle. If you don't understand this, ask me again:

2311121

Hope someone can help!
Message2. Re: Help for programming this riddle?
#1137
Posted by: 2003-12-19 08:05:38
why do you want to use ONE RICHEDIT ? You'd need an unlimited number of lines ..... just buffer the result, a single string suffices. Your line 5 is wrong, it should be 1231.
Message3. Re: Help for programming this riddle?
#1140
Posted by: 2003-12-23 08:27:19
Sorry, but the line 5 isn't wrong!!!
This is the solution:
Line 1: there is "1", so line 2 must be: 11 (one one)
Line 2: there is "11", so line 3 must be: 21 (two ones)
Line 3: there is "21", so line 4 must be: 1211 (one two, one one)

I hope you understand!!! It is really difficult in german to tell you what I mean!

If this "help" don't help, please write to: Marco@m4f.net

I hope to find this puzzle in english, in german it is very difficult to write!!!

Do you know some german people, who program??? My ICQ is: 150537449


Thank you!!!
Message4. Re: Help for programming this riddle?
#1158
Posted by: boltex 2004-02-02 10:52:14
I can do it.
--
b
Message5. Re: Help for programming this riddle?
#1159
Posted by: boltex 2004-02-02 10:55:37
it has nothing to do with richedits, it has to do with recursive parsing.
--
b
Message6. Re: Help for programming this riddle?
#1187
Posted by: 2004-03-16 21:02:53
Since i liked your little riddle, i gave it a shot, et voila it seems to work.
Hope you find it usefull Greetings Lars

 DECLARE SUB DoSolveRiddle

 CREATE Main AS QFORM
  CREATE List AS QRICHEDIT
   Height = Main.clientHeight
   Width  = Main.ClientWidth
  END CREATE
 END CREATE

 DoSolveRiddle

 Main.SHOWMODAL

 SUB DoSolveRiddle

  DIM  NrOfRounds  :  NrOfRounds  = 10 '//   Dont go higher then 28, it will get an error thats the string is too long :(


  DIM  RiddleLine$ :  RiddleLine$ = "1"

  List.AddString "Line 1: " +RiddleLine$

  FOR Rounds = 1 TO NrOfRounds

   FOR Chars = 1 TO LEN(RiddleLine$)
    Char$ = MID$(RiddleLine$,Chars,1)

    IF Chars = 1 THEN
     Count = 1
     PrevChar$ = Char$
    ELSE

     IF Char$ <> PrevChar$ THEN
      NewLine$ = NewLine$ + STR$(Count) + PrevChar$
      Count = 1
      PrevChar$ = Char$
     ELSE
      Count = Count + 1
      PrevChar$ = Char$
     END IF

    END IF

   NEXT Chars

   NewLine$ = NewLine$ + STR$(Count) +Char$
   List.AddString "Line " + STR$(Rounds + 1)+ ": " +NewLine$
   RiddleLine$ = NewLine$
   NewLine$     = ""

  NEXT Rounds


 END SUB

Message7. Re: Help for programming this riddle?
#4568
Posted by: 2004-06-21 18:52:15
Thanks!
That was it! :-)
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2017-9-22  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0