Guidance指路人g.yi.org Guidance Forums / Rapid-Q Basic / Help for programming this riddle?
 最新 LeonAutoBackup
 Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next  1 1. Help for programming this riddle?#1136Posted by: 2003-12-18 22:38:03 Hi!(Richedit)Line1:   1Line2:   11Line3:   21Line4:   1211Line5:   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:2311121Hope someone can help! 2. Re: Help for programming this riddle?#1137Posted 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. 3. Re: Help for programming this riddle?#1140Posted 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.netI 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: 150537449Thank you!!! 4. Re: Help for programming this riddle?#1158Posted by: boltex 2004-02-02 10:52:14 I can do it.--b 5. Re: Help for programming this riddle?#1159Posted by: boltex 2004-02-02 10:55:37 it has nothing to do with richedits, it has to do with recursive parsing. --b 6. Re: Help for programming this riddle?#1187Posted 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 ``` 7. Re: Help for programming this riddle?#4568Posted by: 2004-06-21 18:52:15 Thanks!That was it! :-) Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next  1