combinations algorithm

    Date: 08/19/06 (Algorithms)    Keywords: no keywords

    Forgive me if this is elementary, I've been searching the tubes with no real luck for a while now.

    I'm looking for the description of an algorithm to get all of the unique n-element combinations out of a given set.

    So, given the set

    [A, B, C, D, E]

    and looking for combinations of threes, I'd want:

    [
      [A, B, C],
      [A, B, D],
      [A, B, E],
      [A, C, D],
      [A, C, E],
      [A, D, E],
      [B, C, D],
      [B, C, E],
      [B, D, E],
      [C, D, E]
    ]
    The target language is Ruby, which doesn't appear to have any libraries that do this yet. If you know differently, please let me know :)

    Again, I know this is probably pretty simple, but my foundation is... shaky. Thanks!

    Source: http://community.livejournal.com/algorithms/82856.html

« notation question || Unique... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home