|
|

Available Now

Search

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.


|
| |
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:
 | Permutations Lex up |
 | Permutations Lex down |
 | Permutations Repeat Lex up |
 | Permutations Repeat Lex down |
 | Combinations Lex up |
 | Combinations Lex down |
 | Combinations Repeat Lex up |
 | Combinations Repeat Lex down |
 | Combinations CoLex up |
 | Combinations 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:
September 08, 2006 |
|
|