Thread: algorithm question
10-09-03, 16:53 #1Registered User
- Join Date
- Sep 2003
Unanswered: algorithm question
I am having a hard time trying to figure out something and was wondering if anyone could point me in the right direction,
ok....say I have x number of attributes
How could I write code to find every combination of the 4 letters but no two combinations have the same letters in them.
A,B,C,D,AB,AC,AD,... ABC,BCD...ABCD etc.
and if it has BCD then it won't have CBD.
Also it has to work no matter how many attributes are entered.
Any help would be greatful.
Thanks so much.This message is a natural product made from recycled electrons. The slight
variations in spelling and grammar enhance its individual character and
beauty and in no way are to be considered flaws or defects.
10-17-03, 21:38 #2Registered User
- Join Date
- Oct 2003
This sounds like a homework-problem so I will be vague, but you build up the answer one letter at a time until you reach the desired length, then output, advance to the next letter (or back up a column), and so-on.
It's very useful to use the 'set of char' type to remember what characters are already in the solution.
The only time that I've seen this IS in a homework problem. Although I never used it in my classes, I know the textbooks we used always had it about chapter-4 or so.ChimneySweep(R): fast, automatic
table repair at a click of the