c# - How to find all combinations of an List in sets of two? -
i've tried looking , didn't find i'm trying accomplish.
lets have list<int>
has around 50 numbers
list<int> _mylist = new list<int>(); (int = 0; < 49; i++) { _mylist.add(i); }
how list of combinations based on array two?
for example result set like
1,1
1,2
1,3
1,4
1,5
and considered unique. possible 1,2
same 2,1
?
i'll assume source list called input
:
var output = new list<hashset<int>>(); (int = 0; < input.count; i++) (int j = + 1; j < input.count; j++) output.add(new hashset<int> { input[i], input[j] });
in case want output result console:
foreach (var result in output) console.writeline(string.join(", ", result));
Comments
Post a Comment