# List of possible combinations

I am trying to write some vb.net code that will list all possible combnations of a lst of words.

Currently, I'm interested in the non repeating combination of 4 words "brand", "kind", "size" and "weight".  order is not important.

for example,

I would like to see

brand
brand,kind
brand,kind,size
brand,kind,size,weight

etc

by non repeating I mean for example that
if brand,kind is listed i do not want to see kind,brand

Any ideas???

###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi, try this:

Module Module1

Sub Main()

Dim R As String

For I As Integer = 1 To 15

R = String.Empty

R &= IIf(I And 1, "weight,", "")
R &= IIf(I And 1 << 1, "size,", "")
R &= IIf(I And 1 << 2, "kind,", "")
R &= IIf(I And 1 << 3, "brand,", "")

If R.EndsWith(",") Then
R = R.Substring(0, R.Length - 1)
End If

Console.WriteLine(R)
Next

End Sub

End Module
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Senior .Net DeveloperCommented:
None repeating is easy:

Loop through the array, appending the next word in.

Ex:

Dim x As String() = "r,t".Split(",")

Dim s As String
s = ""
For i As Integer = 0 To x.Length
s = s + x(i)
'output S
Next
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.