Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
9
Task/Permutations/C-sharp/permutations-1.cs
Normal file
9
Task/Permutations/C-sharp/permutations-1.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
public static class Extension
|
||||
{
|
||||
public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> values) where T : IComparable<T>
|
||||
{
|
||||
if (values.Count() == 1)
|
||||
return new[] { values };
|
||||
return values.SelectMany(v => Permutations(values.Where(x => x.CompareTo(v) != 0)), (v, p) => p.Prepend(v));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue