# poker full house!!

• 05-19-2006
noodle24
poker full house!!
I want to print out all 3744 possible poker full houses. Right now I am just assigning cards to be numbers. I'll deal with that later. But here is what I have so far and I'm just getting bad data.

Code:

```int main() { int array[] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; // if there is a pair or                                                               // 3 of  a kind it will add 1                                                               // to the appropriate space int count = 0; //  if count is 2 then there is a full house   for(int i = 0; i <= 51; i++)   {     for(int j = i + 1; j <= 51; j++)     {       for(int k = j + 1; k <= 51; k++)       {         for(int l = k + 1; l <= 51; l++)         {         for(int m = l + 1; m <= 51; m++)         {           int i_i = i % 12;  // this is adding up pairs and 3 of a kind           array[i_i] += 1;           int j_j = j % 12;           array[j_j] += 1;           int k_k = k % 12;           array[k_k] += 1;           int l_l = l % 12;           array[l_l] += 1;           int m_m = m % 12;           array[m_m] += 1;           for(int z = 0; z <= 12; z++)           {                 if(array[z] == 2) count += 1;                 if(array[z] == 3) count += 1;               if(count == 2)               {               cout <<i<<" "<<j<<" "<<k<<" "<<l<<" "<<m<<endl;               }           }         }         }       }     }             // this could very easily be wrong but I don't know when and             // where to reset things               for(int q = 0; q <= 12; ++q)                 {                   array[q] = 0;                 }                 count = 0;   }   return 0; }```
Anybody out there with any advice??
• 05-19-2006
SilentStrike
Conventially, if you want to count from 0 to 99 in C or C++, one writes
Code:

`for (int i = 0; i < 100; ++i)`
Code:

`for (int i = 0; i <= 99; ++i)`
You want to take the numbers mod 13 rather than 12.

This method for detecting a full house is buggy.
Consider
2 Aces
2 Kings
1 Jack

Code:

```           for(int z = 0; z <= 12; z++)           {                 if(array[z] == 2) count += 1;                 if(array[z] == 3) count += 1;               if(count == 2)               {               cout <<i<<" "<<j<<" "<<k<<" "<<l<<" "<<m<<endl;               }           }```
array[z] == 2 twice, so count becomes 2, but you don't actually have a full house.

You should reset your counters right after you detect a full house. You do 5 increments, then you want to cancel those increments out immediately so that you don't start "accumulating" lots and lots of cards in your counter.
• 05-19-2006
King Mir
You only need one variable instead of all those i_i, j_j, k_k ext. Just reasign it each time.

Also in order to include all the combinations, you need to also track card suit.