Posts: 1,956
Threads: 65
Joined: Jun 2003
WHITETIGER,
I don't recognize my original idea in your code, but nevertheless CONGRATULATIONS! It works perfectly given any string of characters and length.
We're going to have to get Progger to grade the winners.
*****
Posts: 2,765
Threads: 138
Joined: Nov 2002
Code:
FOR z = 1 TO l
IF INSTR(s$, LTRIM$(STR$(z))) < 1 THEN EXIT FOR
f$ = ""
IF z = l THEN
FOR z2 = 1 TO l
f$ = f$ + MID$(in$, VAL(MID$(s$, z2, 1)), 1)
NEXT z2
PRINT f$
END IF
NEXT z
this is it.
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 480
Threads: 24
Joined: Mar 2003
Code:
DECLARE SUB PrintCombos (Lead$, Text$)
INPUT "Enter string: ", Text$
CALL PrintCombos("", Text$)
SUB PrintCombos (Lead$, Text$)
IF LEN(Text$) > 1 THEN
FOR CurrentLetter% = 1 TO LEN(Text$)
NewLead$ = Lead$ + MID$(Text$, CurrentLetter%, 1)
NewText$ = LEFT$(Text$, CurrentLetter% - 1) + RIGHT$(Text$, LEN(Text$) - CurrentLetter%)
CALL PrintCombos(NewLead$, NewText$)
NEXT CurrentLetter%
ELSE
PRINT Lead$ + Text$
END IF
END SUB
*peace*
Meg.
i didn't bother getting it to read from DATA and write to a file. those changes could be made easily.
Posts: 1,956
Threads: 65
Joined: Jun 2003
MEG,
I tested your program, and it works 100%. Beautiful job! Nice and simple too. Where were you when we needed you?
P.S. Are you sure you don't have Spanish blood? Your solution is recursive like Antoni's and Nathan's.
*****
Posts: 1,407
Threads: 117
Joined: Dec 2002
Meg:
It is very simple , in addition it works...
Good work!
Where were you when I started the recursion challenge?
Antoni
Posts: 480
Threads: 24
Joined: Mar 2003
I'm sure that I *do* have Spanish blood
My father's mother's entire family lives in Puerto Rico. (I think I end up roughly 1/4 puertorican, 1/4 scottish, 1/4 english, 1/4 italian).
*peace*
Meg.
Posts: 3,288
Threads: 167
Joined: Nov 2001
I am 1/4 spanish. But I don't use recursion that much. ;*( Arrrrgghhhh!!!!
Maybe this chinese bloodline my mom has offsetted my recusive abilities.
;*)
Posts: 354
Threads: 11
Joined: May 2002
Quote:I am 1/4 spanish. But I don't use recursion that much. ;*( Arrrrgghhhh!!!!
Maybe this chinese bloodline my mom has offsetted my recusive abilities.
;*)
I bet you just use it 25% of the time :rotfl:
In a world without walls and doors, who needs Windows and Gates?
Posts: 729
Threads: 105
Joined: Feb 2003
they're all good :o
<-----reconsiders his opinions on recursion, which he avoids like GOTO
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Posts: 3,288
Threads: 167
Joined: Nov 2001
Quote:they're all good :o
<-----reconsiders his opinions on recursion, which he avoids like GOTO
Recursion and goto has there uses. So don't avoid them like you do with Japanese Encephalitis. ;*)