Results 1 to 2 of 2
  1. #1
    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
    ex. ABCD

    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.

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts