diff --git a/AdventOfCode.Extensions/EnumerableExtensions.cs b/AdventOfCode.Extensions/EnumerableExtensions.cs index 119a839..8b68f6e 100644 --- a/AdventOfCode.Extensions/EnumerableExtensions.cs +++ b/AdventOfCode.Extensions/EnumerableExtensions.cs @@ -7,6 +7,15 @@ namespace AdventOfCode.Extensions; public static class EnumerableExtensions { + /// + /// Generates all unique combinations of the specified length from the sequence, preserving the source order within each combination. + /// Each source element can be selected at most once in a generated combination. + /// If is greater than the number of elements in , no combinations are returned. + /// + /// The type of elements in the source sequence. + /// The sequence whose elements are used to build the combinations. + /// The length of each generated combination. + /// A sequence of arrays containing the combinations from . public static IEnumerable Combinations(this IEnumerable values, int count) { var pool = values.ToArray(); @@ -37,7 +46,15 @@ public static class EnumerableExtensions yield return GetCombination(indices, pool); } } - + + /// + /// Generates combinations of the specified length from the sequence, allowing the same source element to be selected multiple times. + /// If is greater than the number of elements in , no combinations are returned. + /// + /// The type of elements in the source sequence. + /// The sequence whose elements are used to build the repeated combinations. + /// The length of each generated combination. + /// A sequence of arrays containing the repeated combinations from . public static IEnumerable CombinationsWithRepeats(this IEnumerable values, int count) { var pool = values.ToArray(); @@ -68,7 +85,15 @@ public static class EnumerableExtensions yield return GetCombination(indices, pool); } } - + + /// + /// Generates ordered permutations of the specified length from the sequence, permitting the same source element to appear multiple times in a selection. + /// If is greater than the number of elements in , no selections are returned. + /// + /// The type of elements in the source sequence. + /// The sequence whose elements are used to build the repeated permutations. + /// The length of each generated permutation. + /// A sequence of arrays containing the ordered repeated permutations from . public static IEnumerable PermutationsWithRepeats(this IEnumerable values, int count) { var pool = values.ToArray(); @@ -96,7 +121,15 @@ public static class EnumerableExtensions yield return GetCombination(indices, pool); } } - + + /// + /// Enumerates ordered permutations of the specified length from the sequence, without reusing the same source position within a permutation. + /// If is greater than the number of elements in , the returned sequence is empty. + /// + /// The type of elements in the sequence. + /// The sequence from which to create permutations. + /// The number of elements to include in each permutation. + /// A sequence of arrays containing the ordered permutations from . public static IEnumerable Permutations(this IEnumerable values, int count) { var pool = values.ToArray();