Click or drag to resize

PermutationGetRows Method

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

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

Return Value

Type: IEnumerablePermutation
An iterator for a Permutation 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 PnExample01
    {
        static void Main()
        {
            var pn = new Permutation (choices:4);

            Console.WriteLine ($"n={pn.Choices}:\n");

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

        /* Output:

        n=4:

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

        */
    }
}
See Also