Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final grade. Summer, as usual, procrastinated much too long, and, having finally looked at her problem, realizes it is considerably more advanced than those covered in her course and has several parts as well. An average programmer, Summer decides to take a Monte Carlo gamble with her grade. Her prof. said that answers could be rounded to the nearest integer, and she doesn't have to show her work. Surely if she lets her program run long enough, her results will be close enough to the exact results one would get "the right way" using probability theory alone.
You (playing alone) are dealt consecutive 13-card hands. Every hand is from a full, shuffled deck. After a certain number of deals, you will have held all 52 cards in the deck at least once. The same can be said for several other goals involving complete suits.
Using your favorite random-number tools, help Summer by writing a program that simulates one million 13-card deals and outputs the average number of deals needed for you to have seen (held) each of these seven goals:
1 (Any) one complete suit 2 One given complete suit 3 (Any) two complete suits 4 Two given suits 5 (Any) three complete suits 6 Three given complete suits 7 The complete deck (all four suits)
Each goal number (1-7) must be followed by the average number of hands needed (rounded to one decimal, which Summer can then round to the nearest integer and turn in) and (just for inquisitive golfers) add the minimum and maximum number of hands needed to reach that goal during the simulation. Provide output from three runs of your program. The challenge is to generate all the averages. The min. and max. are (required) curiosities and will obviously vary run to run.
Sample Output: Three separate million-deal runs for the average, minimum, and maximum number of hands needed to reach each of the seven goals.
1 [7.7, 2, 20 ] 1 [7.7, 3, 18] 1 [7.7, 2, 20 ] 2 [11.6, 3, 50] 2 [11.7, 3, 54] 2 [11.6, 3, 63] 3 [10.0, 4, 25] 3 [10.0, 4, 23] 3 [10.0, 4, 24] 4 [14.0, 5, 61] 4 [14.0, 4, 57] 4 [14.0, 4, 53] 5 [12.4, 6, 30] 5 [12.4, 6, 32] 5 [12.4, 6, 34] 6 [15.4, 6, 51] 6 [15.4, 6, 53] 6 [15.4, 6, 51] 7 [16.4, 7, 48] 7 [16.4, 7, 62] 7 [16.4, 7, 59]
Every hand must be dealt from a full, shuffed deck of 52 standard French playing cards.
Results for each goal must be based on one million hands or deals. You can collect all the results in a single million-deal run, or program as many million-deal runs as you like. However, each of the seven goals should reflect the result of one million deals.
Averages for the number of hands should be rounded to one decimal.
Output should be formatted roughly as above: each goal number (1-7) followed by its results (avg., min., and max. number of hands). Provide output for three runs of your program (side by side or consecutively), which will serve as a check of the accuracy/consistency of the averages (column 1) only (columns 2 and 3 are required, but will obviously vary run to run).
Shortest program in bytes wins.
Note: FYI, I believe the exact calculation (via formula) for the average number of hands needed to see the complete deck (goal # 7) works out to ≈ 16.4121741798
*Good but lazy