title: How to loop through all the combinations of e.g. 48 choose 5
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4504974/how-to-iteratively-generate-k-elements-subsets-from-a-set-of-size-n-in-java">How to iteratively generate k elements subsets from a set of size n in java?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to build my own poker hand evaluator but am having trouble with a particular part.</p>
  
  <p>If two players get dealt a two card hand, then there will be 48 cards left in the pack. In Texas Hold'em a further 5 possible community cards are then dealt (this is called the board). I want to enumerate / loop through all the 48 choose 5 possible combinations of boards and count the times Player A wins and the times Player B wins and when they tie.</p>
  
  <p>I'm not sure how I can systematically loop through every 5 card combination. Does anyone have any ideas? The cards are represented as an array of class Card, but I could also represent them as a bitset if this makes it faster.</p>
  
  <p>I'm doing this in Java. </p>
  
  <p>Many thanks</p>