Comboset Test - Combinations & Permutations

[Home]   [Projects]    [Delphi Techniques]   [Math Topics]   [Library]   [Utilities]

 

Available Now

bullet

All Programs
bulletPuzzles & Projects
bulletDelphi Techniques
bulletMath Topics
bulletUtilities
bulletLibrary Units

Search

Google
 

Search WWW             

Search delphiforfun.org

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Help support DFF

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

 

Google
 

Search WWW

Search delphiforfun.org

 

 

 

This program tests the generating option of our TComboset class  which generates combinations and permutations of various types.

Permutations are subsets selected from a set of objects in every possible 
order. That is, {1,2,3}, {1,3,2}, (2,1,3}, {2,3,1}, {3,1,2}, and {3,2,1} are all 
permutations of the set [1,2,3]. This listing the subsets is increasing 
alphabetical, also called Lexicographical Up. They could also 
logically be listed in reverse sequence, Lexicographical down

If we imagine drawing 3 numbered slips of paper from a hat without replacing 
the slip between draws, permutations represent all possible outcomes. If, on 
the other hand, we replace each slip after drawing and stop after 3 draws, we 
would have many more possible outcomes (3x3x3) or 27 outcomes 
compared to 3x2x1=6 outcomes previously.  This With repeats option is available. 

Combinations on the other hand are selected so that no two subsets have 
the same members. There is only one way to select a combination of 3 out 
of 3 objects. For selecting two of three objects, the combinatorial subsets are 
{1,2}, {1,3}, and {2,3}. These also can be selected with or without repetition, 
and listed "Lexicographical Up" or "Lexicographical Down

For combinations, is also possible redefine the order of the members within 
each set. Normally they are arranged alphabetically, but if they can also be treated as if each subset were arranged in reverse order.  Is is called a CoLexicographic sequence (and just to make things a little more complicated the these subsets can be retrieved in Lexicographic sequence, Up or Down.

So there are 10 retrieval sequences:

bullet Permutations Lex up
bulletPermutations Lex down
bulletPermutations Repeat Lex up
bulletPermutations Repeat Lex down
bulletCombinations Lex up
bulletCombinations Lex down
bulletCombinations Repeat Lex up
bulletCombinations Repeat Lex down
bulletCombinations CoLex up
bulletCombinations CoLex down   

In addition functions are now included to return a Random member from any of the above types, to pass a rank (position in the list) and return that subset, and to Unrank - pass a subset and retrieve its Rank.

The best way to learn to use units to examine the source for the attached test program.  It tests all of the above options and also allows you to replace numeral with strings if you want to see arrangements of letters or car models or fruit.   

TComboset is contained in unit UComboV2 which is in turn zipped with other common usage modules in a Library source file which may be downloaded below.  The unit initializes a single instance of TComboset with name Combos.

Download Combo Test Source (requires DFF Library Source DFFLibV02 or later) 

Download Combo Test Executable

Download DFF Library Source  (Current version DFFLibV11 )

 

Created:  April 3, 2005

Modified: November 07, 2008

 

 

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2008, Gary Darby    All rights reserved.