| Multicombination Constructor (Int32, Int32) |
Initializes a new multicombination from elements supplied in source picked
from the supplied number of choices.
Namespace:
Kaos.Combinatorics
Assembly:
KaosCombinatorics (in KaosCombinatorics.dll) Version: 6.0.0.0
Syntax public Multicombination(
int choices,
int[] source
)
Parameters
- choices
- Type: SystemInt32
Number of values to pick from. - source
- Type: SystemInt32
Array of integers.
Exceptions Remarks
Supplying a value for choices that is greater than the number of elements in source
will instantiate a k-multicombination also known as a k-combination with repetition.
Examples using System;
using Kaos.Combinatorics;
namespace ExampleApp
{
class McExample04
{
static void Main()
{
var mc = new Multicombination (choices:6, picks:4, rank:25);
Console.WriteLine ($"{mc} n={mc.Choices}, k={mc.Picks}, rank={mc.Rank}\n");
mc.Rank = -1;
Console.WriteLine ($"{mc} n={mc.Choices}, k={mc.Picks}, last={mc.Rank}\n");
mc.Rank = mc.Rank + 1;
Console.WriteLine ($"{mc} n={mc.Choices}, k={mc.Picks}, rank={mc.Rank}\n");
mc = new Multicombination (9, new int[] { 1, 1, 3, 8 });
Console.WriteLine ($"{mc} n={mc.Choices}, k={mc.Picks}, rank={mc.Rank}");
}
}
}
See Also