Well, as much as I appreciate what you're doing, I find this easier to read:
int count = 0;
int cards_amount = 52;
for (var first = 0; first < cards_amount-4; first++)
for (var second = first + 1; second < cards_amount-3; second++)
for (var third = second+1; third < cards_amount-2; third++)
for (var fourth = third+1; fourth < cards_amount-1; fourth++)
for (var fifth = fourth+1; fifth < cards_amount; fifth++)
count++;
Instead of looking at all the duplicates, and the if this card is different from the previous
, what I do is: Put all cards in a row. Select the first, and then the second from the remaining, and then the third from the remaining ... and so on.
This way, you don't need to check for multiples, and you get your right answer :)
Edit:
As for the comment ... Just add this line after you initialize your list:
var deck_array = deck.ToArray();
You might want to do this on your class card
:
public override string ToString() {
// have this print your card number & suit
}
And then, just change the count++;
line with this:
{
count ++;
Console.WriteLine("{0},{1},{2},{3},{4}", deck_array[first], deck_array[second],
deck_array[third] , deck_array[fourth] , deck_array[fifth] );
}
Solved ... (now your cards know how to print themselves, and you're just printing the hand at the end.