Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Question Regarding a Card Combinations Program
Index -> Programming, Java -> Java Help
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
OneOffDriveByPoster




PostPosted: Sun Jan 13, 2008 12:32 pm   Post subject: Re: Question Regarding a Card Combinations Program

_Dan_ @ Sun Jan 13, 2008 12:29 pm wrote:
Um yes? Did I do something wrong with the flush method :S?
You don't really need to generate combinations of 4-hands to check that do you? Hint: counters.
Sponsor
Sponsor
Sponsor
sponsor
_Dan_




PostPosted: Sun Jan 13, 2008 12:34 pm   Post subject: Re: Question Regarding a Card Combinations Program

I swear I just realized this before I saw you're post :p. Ya ok thanks! It's still nowhere near efficient enough yet though :p.

New Method:
Java:
public static boolean flushC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int suits[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int suitCounter[] = new int [4];
        for (int card = 0 ; card < 7 ; card++)
        {
            suitCounter [suits [card]]++;
        }
        if (suitCounter [0] == 4 || suitCounter [1] == 4 || suitCounter [2] == 4 || suitCounter [3] == 4)
            return true;
        return false;
    }
OneOffDriveByPoster




PostPosted: Sun Jan 13, 2008 1:06 pm   Post subject: Re: Question Regarding a Card Combinations Program

_Dan_ @ Sun Jan 13, 2008 12:34 pm wrote:
I swear I just realized this before I saw you're post :p. Ya ok thanks! It's still nowhere near efficient enough yet though :p.

New Method:
Java:
public static boolean flushC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int suits[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int suitCounter[] = new int [4];
        for (int card = 0 ; card < 7 ; card++)
        {
            suitCounter [suits [card]]++;
        }
        if (suitsCounter [0] == 4 || suitsCounter [1] == 4 || suitsCounter [2] == 4 || suitsCounter [3] == 4)
            return true;
        return false;
    }
What happens when you have all the same suit (for example)?
_Dan_




PostPosted: Sun Jan 13, 2008 1:10 pm   Post subject: Re: Question Regarding a Card Combinations Program

Ugh -.-.
Sorry I'm being careless, changed to >=.
OneOffDriveByPoster




PostPosted: Sun Jan 13, 2008 1:13 pm   Post subject: Re: Question Regarding a Card Combinations Program

_Dan_ @ Sun Jan 13, 2008 1:10 pm wrote:
Ugh -.-.
Sorry I'm being careless, changed to >=.
Happens to everyone. I think there are some other minor problems though. You have 5 suits and your suit values are not 0-4 so you need to adjust. It really does save you a lot of trouble use 0-based indexing and start numbering things from 0 (convert on input and output).
_Dan_




PostPosted: Sun Jan 13, 2008 1:16 pm   Post subject: Re: Question Regarding a Card Combinations Program

I got an array index out of bounds error before I posted it, so I fixed this :p, I also only checked 4 suits I believe, not 5, I fixed this before my last post as well :p, I'm making the program print out 1 in every 1 million hands it goes through, and I've calculated that it will take 16 minutes to go through all hands, so I guess that's bearable :p. Unless my calculations are incorrect, I think I don't need anymore help for now XD, once again thanks a bunch for all the help.
OneOffDriveByPoster




PostPosted: Sun Jan 13, 2008 1:39 pm   Post subject: Re: Question Regarding a Card Combinations Program

_Dan_ @ Sun Jan 13, 2008 1:16 pm wrote:
I got an array index out of bounds error before I posted it, so I fixed this :p, I also only checked 4 suits I believe, not 5, I fixed this before my last post as well :p, I'm making the program print out 1 in every 1 million hands it goes through, and I've calculated that it will take 16 minutes to go through all hands, so I guess that's bearable :p. Unless my calculations are incorrect, I think I don't need anymore help for now XD, once again thanks a bunch for all the help.
No problem. FYI, I think this is the math way for how many 7-hands has 4-hands that are flushes:
5 suits, 10 values; nCr is how many combinations you can have if you choose r objects from n objects.
5 * (10C4 * 40C3 + 10C5 * 40C2 + 10C6 * 40C1 + 10C7 * 40C0)
_Dan_




PostPosted: Sun Jan 13, 2008 1:49 pm   Post subject: Re: Question Regarding a Card Combinations Program

I already calculated the flushes and prime ones actually Razz (exactly the way you did), it was the other ones that were tricky, for example if you wanted to calculate how many straights occurred, you would need hundreds of cases I believe.

Weird... Here is the output I got:
All Divide: 29439900, 29.473971911529727%
All Prime: 35049250, 35.089813824781444%
Straights: 13721875, 13.737755845757697%
Flushes: 3337260, 3.3411223374220596%
Straight Flushes: 1102220, 1.1034956409609509%
Prime Flushes: 1240701, 1.24213691026827%
Divide Flushes: 361262, 0.36168010219814106%
Total: 99884400

The flush % is incorrect :S.
It should be: 11,399,400 and a % of 11.41..

And as for primes. The math would be:

i) 4 Primes: 25C4 * 25C3
ii) 5 Primes: 25C5 * 25C2
iii) 6 primes: 25C6 * 25C1
iv) 7 primes: 25C7 * 25C0
i+ii+iii+iv = 49,942,200

With a percentage of 50%

Must be something wrong with the method :S.
Sponsor
Sponsor
Sponsor
sponsor
OneOffDriveByPoster




PostPosted: Sun Jan 13, 2008 1:57 pm   Post subject: Re: Question Regarding a Card Combinations Program

_Dan_ @ Sun Jan 13, 2008 1:49 pm wrote:
The flush % is incorrect :S.
It should be: 11,399,400 and a % of 11.41..
I had to fix your loop for populating the suits[] array in main().
_Dan_




PostPosted: Sun Jan 13, 2008 1:58 pm   Post subject: Re: Question Regarding a Card Combinations Program

Oh ok, I'll take a look, I also made the prog more efficient by making the prime hand checker similar to the new flush one.

Wait what's wrong with it -.-.

Here's my new code by the way:
Java:
import java.awt.Color;
import hsa.Console;
import java.util.*;

/** The "Check" class.
  * Purpose:
  * @Author
  * @Last Updated:
 */

public class Check
{
    public static boolean isPrime (int value)
    {
        if (value < 4)
        {
            return true;
        }
        if (value == 5 || value == 7 || value == 11)
            return true;
        return false;
    }


    public static boolean allDivideC (int fCard, int sCard, int tCard,
            int foCard, int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        for (int f = 0 ; f < 7 ; f++)
        {
            for (int s = f + 1 ; s < 7 ; s++)
            {
                for (int t = s + 1 ; t < 7 ; t++)
                {
                    for (int fo = t + 1 ; fo < 7 ; fo++)
                    {
                        int largest = values [f];
                        if (values [s] > largest)
                            largest = values [s];
                        if (values [t] > largest)
                            largest = values [t];
                        if (values [fo] > largest)
                            largest = values [fo];
                        if (largest % values [f] == 0 &&
                                largest % values [s] == 0 &&
                                largest % values [t] == 0 &&
                                largest % values [fo] == 0)
                            return true;
                    }
                }
            }
        }
        return false;
    }


    public static boolean flushC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int suits[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int suitCounter[] = new int [6];
        for (int card = 0 ; card < 7 ; card++)
        {
            suitCounter [suits [card]]++;
        }
        if (suitCounter [1] >= 4 || suitCounter [2] >= 4 || suitCounter [3] >= 4 || suitCounter [4] >= 4 || suitCounter [5] >= 4)
            return true;
        return false;
    }


    public static boolean straightC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        for (int f = 0 ; f < 7 ; f++)
        {
            for (int s = f + 1 ; s < 7 ; s++)
            {
                for (int t = s + 1 ; t < 7 ; t++)
                {
                    for (int fo = t + 1 ; fo < 7 ; fo++)
                    {
                        int[] hand = {values [f], values [s], values [t],
                            values [fo] };
                        Arrays.sort (hand);
                        if (values [fo] == values [f] + 3 &&
                                values [t] == values [f] + 2 &&
                                values [s] == values [f] + 1)
                            return true;
                    }
                }
            }
        }
        return false;
    }


    public static boolean isPrimeC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int primeCounter = 0;
        for (int card = 0 ; card < 7 ; card++)
        {
            if (isPrime (values [card]))
                primeCounter++;
        }
        if (primeCounter >= 4)
            return true;

        return false;
    }



    public static void main (String[] args)
    {
        int allDivide = 0;
        int allPrime = 0;
        int straight = 0;
        int flush = 0;
        int straightFlush = 0;
        int primeFlush = 0;
        int divideFlush = 0;
        int total = 0;
        int[] suits = new int [50];
        for (int counter = 1 ; counter < 6 ; counter++)
        {
            for (int increment = 1 ; increment < 11 ; increment++)
            {
                suits [increment * counter - 1] = counter;
            }
        }


        int[] values = new int [50];
        for (int increment = 0 ; increment < 50 ; increment += 5)
        {
            for (int suit = 0 ; suit < 5 ; suit++)
            {
                values [increment + suit] = (increment / 5) + 2;
            }
        }


        for (int f = 0 ; f < 50 ; f++)
        {
            for (int s = f + 1 ; s < 50 ; s++)
            {
                for (int t = s + 1 ; t < 50 ; t++)
                {
                    for (int fo = t + 1 ; fo < 50 ; fo++)
                    {
                        for (int fi = fo + 1 ; fi < 50 ; fi++)
                        {
                            for (int si = fi + 1 ; si < 50 ; si++)
                            {
                                for (int se = si + 1 ; se < 50 ; se++)
                                {
                                    total++;
                                    boolean allDivideB = false;
                                    boolean allPrimeB = false;
                                    boolean straightB = false;
                                    boolean flushB = false;

                                    if (allDivideC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        allDivideB = true;

                                    if (isPrimeC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        allPrimeB = true;

                                    if (straightC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        straightB = true;

                                    if (flushC (suits [f], suits [s], suits [t],
                                                suits [fo], suits [fi],
                                                suits [si], suits [se]))
                                        flushB = true;

                                    if (flushB)
                                        flush++;
                                    if (allDivideB)
                                        allDivide++;
                                    else if (allPrimeB)
                                        allPrime++;
                                    else if (straightB)
                                        straight++;

                                    if (flushB && straightB)
                                    {
                                        straightFlush++;
                                    }
                                    else if (flushB && allPrimeB)
                                    {
                                        primeFlush++;
                                    }
                                    else if (flushB && allDivideB)
                                    {
                                        divideFlush++;
                                    }
                                    if (total % 1000000 == 0)
                                    {
                                        System.out.print (values [f]);
                                        System.out.print (" ");
                                        System.out.print (values [s]);
                                        System.out.print (" ");
                                        System.out.print (values [t]);
                                        System.out.print (" ");
                                        System.out.print (values [fo]);
                                        System.out.print (" ");
                                        System.out.print (values [fi]);
                                        System.out.print (" ");
                                        System.out.print (values [si]);
                                        System.out.print (" ");
                                        System.out.println (values [se]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }


        System.out.println ("All Divide: " + allDivide +
                ", " + (1.0 * allDivide / total * 100) + "%");
        System.out.println ("All Prime: " + allPrime +
                ", " + (1.0 * allPrime / total * 100) + "%");
        System.out.println ("Straights: " + straight +
                ", " + (1.0 * straight / total * 100) + "%");
        System.out.println ("Flushes: " + flush +
                ", " + (1.0 * flush / total * 100) + "%");
        System.out.println ("Straight Flushes: " + straightFlush +
                ", " + (1.0 * straightFlush / total * 100) + "%");
        System.out.println ("Prime Flushes: " + primeFlush +
                ", " + (1.0 * primeFlush / total * 100) + "%");
        System.out.println ("Divide Flushes: " + divideFlush +
                ", " + (1.0 * divideFlush / total * 100) + "%");
        System.out.println ("Total: " + total);

    } // main method
} // Check class
OneOffDriveByPoster




PostPosted: Sun Jan 13, 2008 2:06 pm   Post subject: Re: Question Regarding a Card Combinations Program

I could tell you, but try printing the array to see first.
_Dan_




PostPosted: Sun Jan 13, 2008 2:16 pm   Post subject: Re: Question Regarding a Card Combinations Program

Testing the allPrime and flush hands now.

Java:
import java.awt.Color;
import hsa.Console;
import java.util.*;

/** The "Check" class.
  * Purpose:
  * @Author
  * @Last Updated:
 */

public class Check
{
    public static boolean isPrime (int value)
    {
        if (value == 2 || value == 3 || value == 5 || value == 7 || value == 11)
            return true;
        return false;
    }


    public static boolean allDivideC (int fCard, int sCard, int tCard,
            int foCard, int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        for (int f = 0 ; f < 7 ; f++)
        {
            for (int s = f + 1 ; s < 7 ; s++)
            {
                for (int t = s + 1 ; t < 7 ; t++)
                {
                    for (int fo = t + 1 ; fo < 7 ; fo++)
                    {
                        int largest = values [f];
                        if (values [s] > largest)
                            largest = values [s];
                        if (values [t] > largest)
                            largest = values [t];
                        if (values [fo] > largest)
                            largest = values [fo];
                        if (largest % values [f] == 0 &&
                                largest % values [s] == 0 &&
                                largest % values [t] == 0 &&
                                largest % values [fo] == 0)
                            return true;
                    }
                }
            }
        }
        return false;
    }


    public static boolean flushC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int suits[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int suitCounter[] = new int [6];
        for (int card = 0 ; card < 7 ; card++)
            suitCounter [suits [card]]++;
        if (suitCounter [1] >= 4 || suitCounter [2] >= 4 || suitCounter [3] >= 4 || suitCounter [4] >= 4 || suitCounter [5] >= 4)
            return true;
        return false;
    }


    public static boolean straightC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        for (int f = 0 ; f < 7 ; f++)
        {
            for (int s = f + 1 ; s < 7 ; s++)
            {
                for (int t = s + 1 ; t < 7 ; t++)
                {
                    for (int fo = t + 1 ; fo < 7 ; fo++)
                    {
                        int[] hand = {values [f], values [s], values [t],
                            values [fo] };
                        Arrays.sort (hand);
                        if (values [fo] == values [f] + 3 &&
                                values [t] == values [f] + 2 &&
                                values [s] == values [f] + 1)
                            return true;
                    }
                }
            }
        }
        return false;
    }


    public static boolean isPrimeC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int primeCounter = 0;
        for (int card = 0 ; card < 7 ; card++)
            if (isPrime (values [card]))
                primeCounter++;
        if (primeCounter >= 4)
            return true;
        return false;
    }



    public static void main (String[] args)
    {
        int allDivide = 0;
        int allPrime = 0;
        int straight = 0;
        int flush = 0;
        int straightFlush = 0;
        int primeFlush = 0;
        int divideFlush = 0;
        int total = 0;
        int[] suits = new int [50];
        for (int suitCounter = 0 ; suitCounter < 5 ; suitCounter += 1)
        {
            for (int valueCounter = 0 ; valueCounter < 10 ; valueCounter++)
                suits [valueCounter + suitCounter * 10] = (suitCounter) + 1;
        }

        for (int counter = 0 ; counter < 50 ; counter++)
            System.out.println (suits [counter]);

        int[] values = new int [50];
        for (int increment = 0 ; increment < 50 ; increment += 5)
            for (int suit = 0 ; suit < 5 ; suit++)
                values [increment + suit] = (increment / 5) + 2;

        for (int f = 0 ; f < 50 ; f++)
        {
            for (int s = f + 1 ; s < 50 ; s++)
            {
                for (int t = s + 1 ; t < 50 ; t++)
                {
                    for (int fo = t + 1 ; fo < 50 ; fo++)
                    {
                        for (int fi = fo + 1 ; fi < 50 ; fi++)
                        {
                            for (int si = fi + 1 ; si < 50 ; si++)
                            {
                                for (int se = si + 1 ; se < 50 ; se++)
                                {
                                    total++;
                                    boolean allDivideB = false;
                                    boolean allPrimeB = false;
                                    boolean straightB = false;
                                    boolean flushB = false;

                                    if (allDivideC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        allDivideB = true;

                                    if (isPrimeC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        allPrimeB = true;

                                    if (straightC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        straightB = true;

                                    if (flushC (suits [f], suits [s], suits [t],
                                                suits [fo], suits [fi],
                                                suits [si], suits [se]))
                                        flushB = true;

                                    if (flushB)
                                        flush++;
                                    if (allDivideB)
                                        allDivide++;
                                    else if (allPrimeB)
                                        allPrime++;
                                    else if (straightB)
                                        straight++;
                                    if (flushB && straightB)
                                        straightFlush++;
                                    else if (flushB && allPrimeB)
                                        primeFlush++;
                                    else if (flushB && allDivideB)
                                        divideFlush++;

                                    if (total % 1000000 == 0)
                                    {
                                        System.out.print (values [f]);
                                        System.out.print (" ");
                                        System.out.print (values [s]);
                                        System.out.print (" ");
                                        System.out.print (values [t]);
                                        System.out.print (" ");
                                        System.out.print (values [fo]);
                                        System.out.print (" ");
                                        System.out.print (values [fi]);
                                        System.out.print (" ");
                                        System.out.print (values [si]);
                                        System.out.print (" ");
                                        System.out.println (values [se]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }


        System.out.println ("All Divide: " + allDivide +
                ", " + (1.0 * allDivide / total * 100) + "%");
        System.out.println ("All Prime: " + allPrime +
                ", " + (1.0 * allPrime / total * 100) + "%");
        System.out.println ("Straights: " + straight +
                ", " + (1.0 * straight / total * 100) + "%");
        System.out.println ("Flushes: " + flush +
                ", " + (1.0 * flush / total * 100) + "%");
        System.out.println ("Straight Flushes: " + straightFlush +
                ", " + (1.0 * straightFlush / total * 100) + "%");
        System.out.println ("Prime Flushes: " + primeFlush +
                ", " + (1.0 * primeFlush / total * 100) + "%");
        System.out.println ("Divide Flushes: " + divideFlush +
                ", " + (1.0 * divideFlush / total * 100) + "%");
        System.out.println ("Total: " + total);

    } // main method
} // Check class
_Dan_




PostPosted: Sun Jan 13, 2008 2:35 pm   Post subject: Re: Question Regarding a Card Combinations Program

Ok it's working, now I just need to figure out what's wrong with the prime one :S.
Tony




PostPosted: Sun Jan 13, 2008 2:45 pm   Post subject: RE:Question Regarding a Card Combinations Program

yes, you don't need any of the for-loops.

similarly you don't need 4 for-loops for straightC, one will do just fine (Hint: sort the 7-card pool before the loop) (Hint2: the loop is from 0 to 3)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
_Dan_




PostPosted: Sun Jan 13, 2008 2:51 pm   Post subject: Re: Question Regarding a Card Combinations Program

Arg I forgot about that! I used a similar method for a poker hand problem in comp sci class -.-.
Updated.

But why are the numbers for the all prime hands incorrect?

Also is my straight code correct -.-, it's giving me different numbers.
Java:
import java.awt.Color;
import hsa.Console;
import java.util.*;

/** The "Check" class.
  * Purpose:
  * @Author
  * @Last Updated:
 */

public class Check
{
    public static boolean isPrime (int value)
    {
        if (value == 2 || value == 3 || value == 5 || value == 7 || value == 11)
            return true;
        return false;
    }


    public static boolean allDivideC (int fCard, int sCard, int tCard,
            int foCard, int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        for (int f = 0 ; f < 7 ; f++)
        {
            for (int s = f + 1 ; s < 7 ; s++)
            {
                for (int t = s + 1 ; t < 7 ; t++)
                {
                    for (int fo = t + 1 ; fo < 7 ; fo++)
                    {
                        int largest = values [f];
                        if (values [s] > largest)
                            largest = values [s];
                        if (values [t] > largest)
                            largest = values [t];
                        if (values [fo] > largest)
                            largest = values [fo];
                        if (largest % values [f] == 0 &&
                                largest % values [s] == 0 &&
                                largest % values [t] == 0 &&
                                largest % values [fo] == 0)
                            return true;
                    }
                }
            }
        }
        return false;
    }


    public static boolean flushC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int suits[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int suitCounter[] = new int [6];
        for (int card = 0 ; card < 7 ; card++)
            suitCounter [suits [card]]++;
        if (suitCounter [1] >= 4 || suitCounter [2] >= 4 || suitCounter [3] >= 4 || suitCounter [4] >= 4 || suitCounter [5] >= 4)
            return true;
        return false;
    }


    public static boolean straightC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        Arrays.sort (values);
        for (int f = 0 ; f < 3 ; f++)
        {
            if (values [f] == values [f + 1] - 1 && values [f] == values [f + 2] - 2 && values [f] == values [f + 3] - 3)
                return true;
        }
        return false;
    }


    public static boolean isPrimeC (int fCard, int sCard, int tCard, int foCard,
            int fiCard, int siCard, int seCard)
    {
        int values[] = {fCard, sCard, tCard, foCard, fiCard, siCard, seCard};
        int primeCounter = 0;
        for (int card = 0 ; card < 7 ; card++)
            if (isPrime (values [card]))
                primeCounter++;
        if (primeCounter >= 4)
            return true;
        return false;
    }



    public static void main (String[] args)
    {
        int allDivide = 0;
        int allPrime = 0;
        int straight = 0;
        int flush = 0;
        int straightFlush = 0;
        int primeFlush = 0;
        int divideFlush = 0;
        int total = 0;
        int[] suits = new int [50];
        for (int suitCounter = 0 ; suitCounter < 5 ; suitCounter += 1)
        {
            for (int valueCounter = 0 ; valueCounter < 10 ; valueCounter++)
                suits [valueCounter + suitCounter * 10] = (suitCounter) + 1;
        }


        int[] values = new int [50];
        for (int increment = 0 ; increment < 50 ; increment += 5)
            for (int suit = 0 ; suit < 5 ; suit++)
                values [increment + suit] = (increment / 5) + 2;

        for (int f = 0 ; f < 50 ; f++)
        {
            for (int s = f + 1 ; s < 50 ; s++)
            {
                for (int t = s + 1 ; t < 50 ; t++)
                {
                    for (int fo = t + 1 ; fo < 50 ; fo++)
                    {
                        for (int fi = fo + 1 ; fi < 50 ; fi++)
                        {
                            for (int si = fi + 1 ; si < 50 ; si++)
                            {
                                for (int se = si + 1 ; se < 50 ; se++)
                                {
                                    total++;
                                    boolean allDivideB = false;
                                    boolean allPrimeB = false;
                                    boolean straightB = false;
                                    boolean flushB = false;

                                    if (allDivideC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        allDivideB = true;

                                    if (isPrimeC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        allPrimeB = true;

                                    if (straightC (values [f], values [s],
                                                values [t], values [fo],
                                                values [fi], values [si],
                                                values [se]))
                                        straightB = true;

                                    if (flushC (suits [f], suits [s], suits [t],
                                                suits [fo], suits [fi],
                                                suits [si], suits [se]))
                                        flushB = true;

                                    if (flushB)
                                        flush++;
                                    if (allDivideB)
                                        allDivide++;
                                    else if (allPrimeB)
                                        allPrime++;
                                    else if (straightB)
                                        straight++;
                                    if (flushB && straightB)
                                        straightFlush++;
                                    else if (flushB && allPrimeB)
                                        primeFlush++;
                                    else if (flushB && allDivideB)
                                        divideFlush++;

                                    if (total % 1000000 == 0)
                                    {
                                        System.out.print (total / 1000000);
                                        System.out.print (" ");
                                        System.out.print (values [f]);
                                        System.out.print (" ");
                                        System.out.print (values [s]);
                                        System.out.print (" ");
                                        System.out.print (values [t]);
                                        System.out.print (" ");
                                        System.out.print (values [fo]);
                                        System.out.print (" ");
                                        System.out.print (values [fi]);
                                        System.out.print (" ");
                                        System.out.print (values [si]);
                                        System.out.print (" ");
                                        System.out.println (values [se]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }


        System.out.println ("All Divide: " + allDivide +
                ", " + (1.0 * allDivide / total * 100) + "%");
        System.out.println ("All Prime: " + allPrime +
                ", " + (1.0 * allPrime / total * 100) + "%");
        System.out.println ("Straights: " + straight +
                ", " + (1.0 * straight / total * 100) + "%");
        System.out.println ("Flushes: " + flush +
                ", " + (1.0 * flush / total * 100) + "%");
        System.out.println ("Straight Flushes: " + straightFlush +
                ", " + (1.0 * straightFlush / total * 100) + "%");
        System.out.println ("Prime Flushes: " + primeFlush +
                ", " + (1.0 * primeFlush / total * 100) + "%");
        System.out.println ("Divide Flushes: " + divideFlush +
                ", " + (1.0 * divideFlush / total * 100) + "%");
        System.out.println ("Total: " + total);

    } // main method
} // Check class
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 36 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: