Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My failed challenge, combination list
#11
perhaps I'm understanding the problem wrong?

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

Doesn't this do what you described?

*peace*

Meg.

p.s. Making it read from DATA statements and write to a file can be done pretty simply.. I didn't realize that is what you wanted it to do. Just change the last PRINT to send to file, and read in the data before the first CALL.
Reply
#12
Nothin' wrong with that.
Reply
#13
Good, but RECURSION! (points a bloody finger)
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#14
Meg,
Please read my comments posted on the original challenge thread for this subject.
*****
Reply
#15
Wow... :o
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]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)