Click or drag to resize

CombinationGetRows Method

Iterate thru all rows of the Combination table for every Rank ascending.

Namespace:  Kaos.Combinatorics
Assembly:  KaosCombinatorics (in KaosCombinatorics.dll) Version: 6.0.0.0
Syntax
C#
public IEnumerable<Combination> GetRows()

Return Value

Type: IEnumerableCombination
An iterator for a Combination table.
Remarks
If the start row is not Rank 0, the iteration will wrap around so that RowCount items are always produced.
Examples
C#
using System;
using Kaos.Combinatorics;

namespace ExampleApp
{
    class CnExample01
    {
        static void Main()
        {
            var cn = new Combination (choices:6, picks:3);

            Console.WriteLine ($"n={cn.Choices}, k={cn.Picks}:\n");

            foreach (var row in cn.GetRows())
                Console.WriteLine ($"{row.Rank,2}:  {row}");
        }

        /* Output:

        n=6, k=3:

         0:  { 0, 1, 2 }
         1:  { 0, 1, 3 }
         2:  { 0, 1, 4 }
         3:  { 0, 1, 5 }
         4:  { 0, 2, 3 }
         5:  { 0, 2, 4 }
         6:  { 0, 2, 5 }
         7:  { 0, 3, 4 }
         8:  { 0, 3, 5 }
         9:  { 0, 4, 5 }
        10:  { 1, 2, 3 }
        11:  { 1, 2, 4 }
        12:  { 1, 2, 5 }
        13:  { 1, 3, 4 }
        14:  { 1, 3, 5 }
        15:  { 1, 4, 5 }
        16:  { 2, 3, 4 }
        17:  { 2, 3, 5 }
        18:  { 2, 4, 5 }
        19:  { 3, 4, 5 }

        */
    }
}
See Also