Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combination, Not Permutation, Algorithm

Status
Not open for further replies.

SleepDepD

Programmer
Mar 13, 2004
65
US
I'm looking for a combinatorial algorithm written in VB; a function that would list every possible combination of characters in a given string "ABC". I've found a lot of algorithms outputting permutations:
Code:
ABC,BCA,CAB,...
but none of all combinations
Code:
A,AB,ABC,...
If anyone has one, I would appreciate the help.
 
Think binary. In "All Combinations", a letter is either In or Out ("on" or "Off"). For "ABC", it is 0 thu 7(2^3 - 1)..."A" if 4 is on, "B" if 2 is on and "C" if 1 is on.
0="",1="C",2="B",3="BC",4="A",5="AC",6="AB",7="ABC"

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top