Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, as much as I appreciate what you're doing, I find this easier to read:</p> <pre><code>int count = 0; int cards_amount = 52; for (var first = 0; first &lt; cards_amount-4; first++) for (var second = first + 1; second &lt; cards_amount-3; second++) for (var third = second+1; third &lt; cards_amount-2; third++) for (var fourth = third+1; fourth &lt; cards_amount-1; fourth++) for (var fifth = fourth+1; fifth &lt; cards_amount; fifth++) count++; </code></pre> <p>Instead of looking at all the duplicates, and the <code>if this card is different from the previous</code>, 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.</p> <p>This way, you don't need to check for multiples, and you get your right answer :)</p> <p><strong>Edit:</strong><br> As for the comment ... Just add this line after you initialize your list: </p> <pre><code>var deck_array = deck.ToArray(); </code></pre> <p>You might want to do this on your <code>class card</code>:</p> <pre><code>public override string ToString() { // have this print your card number &amp; suit } </code></pre> <p>And then, just change the <code>count++;</code> line with this:</p> <pre><code>{ count ++; Console.WriteLine("{0},{1},{2},{3},{4}", deck_array[first], deck_array[second], deck_array[third] , deck_array[fourth] , deck_array[fifth] ); } </code></pre> <p>Solved ... (now your cards know how to print themselves, and you're just printing the hand at the end.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload