combinations - C# Combine many IList<char> to make a new List -
i have permutations of type ilist each 1 having 6 elements e.g. 1, 1, 3, 2, 2, 2
so in permutations collection may have 2 lists looking 1, 1, 3, 2, 2, 2 & other 1, 1, 2, 3, 2, 2
i need combine them resulting combination beingness 1, 1 , 2/3, 2/3, 2, 2.
but combining needs applied permutations in list. bellow code suggested works, combining should reducing items in collection, after combining them im left same amount of permutations combined?
foreach (ilist<char> p in permutationcollection) { var result = p.zip(permutationcollection.elementat(x + 1), (first, second) => { if (first != second) { homecoming first + " / " + second; } else homecoming second.tostring(); }); }
linq zip trick http://msdn.microsoft.com/en-us/library/vstudio/dd267698(v=vs.100).aspx
i.e.
int[] numbers = { 1, 1, 3, 2, 2, 2 }; int[] words = { 1, 1, 2, 3, 2, 2 }; var result = numbers.zip(words, (first, second) => {if(first != second) {return first + " / " + second;} else homecoming second.tostring(); });
c# combinations permutation ilist
No comments:
Post a Comment