• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Update: Tough C++ nut to crack

Update: Ok here's my new problem.

Using a Monte Carlo simulation, estimate the possibility of getting a "Full House" (three cards of the same rank plus a par, also matching in rank) on a random deal out of a deck of 52 cards (4 suits, 13 cards of different ranks in each suit). Compare your estimate with the theoretical result, 6/4165.

I remember what the Monte Carlo method is, but I'm having a hard time coming up with a algorith to solve the problem.
 
apstring is just a class made up by the AP College Board because they think letting people use real strings would be too dangerous.
 
Ughh. I don't necessarily need the code. I don't get how I'm going to set the program up.

Am I going to need an enumerated data type?

enum suit { DIAMOND, HEART, SPAID, CLUB };

Then I know I'm going to need to set up an apvector of type suit.

apvector<suit> possibleCards(52);

or should I set up the apvector to handle the 5 card draw (replace the 52 with 5). Geez this one is going to take me a while.
 
Is the program supposed to calculate the probability using a combination formula (I don't remember the exact calculation, that was last yrs math for me), or by randomly choosing 5 cards continuously until it comes upon a full house, then output the probability based on the number of tries it took?
 
Pretender, your guess is as good as mine. The problem is typed out word-for-word in my first post (its copied directly off the worksheet).

I'm still working out the algorithm. 😱
 
oh the combination forumula is n! /r!(n-r)! something like that. You are gonna have to write a factorialing function should be real easy. r up there is the number of options, n is the number of things you will pick. its a pretty tought problem i guess, if this were my own project i'd work on it, but its not. But if you have a factorial function and the combination forumula you should be able to do it. I think its just the probability of choosing 3 of a kind of a card * the probability of getting a pair.
 
I think you are supposed to run a Monte Carlo simulation.

Basically, randomly picked 52 cards for about n times (n
should be big, like 100,000 or more), and then record
how many times you come up with a Full House.
The probability calculated from your program should be
= # of Full House / n

Compare the result that you get from the program with theoretical
result which is 6/4165.
 
Back
Top