Click or drag to resize

MulticombinationItem Property

Get a element of the Multicombination at the supplied column.

Namespace:  Kaos.Combinatorics
Assembly:  KaosCombinatorics (in KaosCombinatorics.dll) Version: 5.0.0.6
Syntax
C#
public int this[
	int index
] { get; }

Parameters

index
Type: SystemInt32
Zero-based index value.

Return Value

Type: Int32
Sequence value at index.
Exceptions
ExceptionCondition
IndexOutOfRangeException When index not in range (0..Picks-1).
Examples
C#
using System;
using System.Linq;
using Kaos.Combinatorics;

namespace ExampleApp
{
    class McExample05
    {
        static void Main()
        {
            // Create a k-multicombination:
            var mc = new Multicombination (choices:9, picks:7, rank:5973);
            Console.WriteLine ($"n={mc.Choices}, k={mc.Picks}, rank={mc.Rank}:\n");

            // Access elements using the default enumerator:
            var text = String.Concat (mc.Select (ei => (char) ('A' + ei)));
            Console.WriteLine ($"{text}\n");

            // Access elements using the indexer:
            for (int i = 0; i < mc.Picks; ++i)
                Console.WriteLine ($"Element at {i} is {mc[i]}");
        }

        /* Output:

        n=9, k=7, rank=5973:

        DEFFFHI

        Element at 0 is 3
        Element at 1 is 4
        Element at 2 is 5
        Element at 3 is 5
        Element at 4 is 5
        Element at 5 is 7
        Element at 6 is 8

        */
    }
}
See Also