Summer Klerance turned in her term assignment for this challenge. Her professor was miffed (but also amused) when he overheard a disgruntled classmate of Summer's saying she got her answers by simulation rather than by the probabilistic methods covered in the course. Summer received a note to see the prof during his next office hours.

"OK, Miss Smarty-Pants*, I'll admit your problem was harder than any of the others I assigned. However, I'm not ready to give you full credit...Have a seat! If we order the goals by increasing difficulty of achievement, which you already, um, "found," we have:

The Prof's New Order:

1 (Any) one complete suit [7.7 hands]
3 (Any) two complete suits [10.0 hands]
2 One given complete suit [11.6 hands]
5 (Any) three complete suits [12.4 hands]
4 Two given complete suits [14.0 hands]
6 Three given complete suits [15.4 hands]
7 The complete deck (all four suits) [16.4 hands]

The Challenge:

"I'd like you to modify your program. Keep track of the number of hands needed to see each of the seven goals as you deal, just as before. Let's define one trial as being completed on the hand when you've achieved all seven goals, i.e. a complete deck. The order in which you achieved each of the seven goals during a trial may or may not match the New Order I've shown you. To receive full credit for you term problem, I'd like you to tack a single number onto your output: the percentage of total trials in which the order of goal achievement exactly matches the New Order. And let's change our sample from 1 million deals to 20,000 trials to ensure there is no partial trial at the end."

Input: None

Output: Same format as the original challenge with two changes: (a) the addition of the new percentage at the end of the output, and (b) a program run of exactly 20,000 trials, instead of the 1 million deals in the previous challenge.

Rules (revised):

(1) The results for the seven goals should be output in the Old Order (1-7) and not the New Order above. However, the percentage of interest is based on the New Order above, that of strictly increasing difficulty of achievement.

(2) Runs are no longer based on 1 million deals, but rather 20,000 completed trials (roughly 330,000 deals).

(3) A tie resulting from achieving two or more goals on the same deal counts as a Yes, since it (also) fulfills the New Order requirement.

(4) The new number should come at the end of the output and needn't have a % sign.

(5) Show the result of three program runs, as in the original challenge. The data requested for each of the seven goals remains analogous to the original challenge: goal number; average number of hands needed in the 20,000 trials (rounded to one decimal place); minimum number of hands needed; and the maximum number of hands needed. The newly requested percentage should be at the end of the output.

(6) Code golf, so shortest club code in bytes wins.

*He didn't actually say that, but it was what he was thinking.

  • 2
    \$\begingroup\$ How are ties handled? Ie, if two goals are reached at the same time, does that count as a failure run? Sidenote: I like this challenge and the other, but I recommend avoiding finnicky output rules like (3) in the future. They almost always make challenges less fun, and add little. \$\endgroup\$
    – Jonah
    Jul 26, 2021 at 5:11
  • 3
    \$\begingroup\$ Points taken, thank you. I propose I change the rules to (1) stipulate the percentage just has to be at the end of the output without a % sign; (2) say ties count as fulfilling the New Order. Thoughts? \$\endgroup\$
    – DjinTonic
    Jul 26, 2021 at 11:15
  • 1
    \$\begingroup\$ Rules have been revised \$\endgroup\$
    – DjinTonic
    Jul 26, 2021 at 12:27

2 Answers 2


Jelly, 96 78 bytes


Try it online!

A full program which is called as with no arguments and returns a list of lists of numbers. Each goal is represented in order as [goal number, [mean, min, max]] while the eighth list member is the percentage of trials matching the specified order. This is an extension of my previous Jelly answer to the first part. The TIO link runs three lots of 500 (5E2) trials rather than 20,000 (2E5).

  • \$\begingroup\$ I stipulated in the Rules that the percentage should be followed by the % sign. Do you want to add it, or should I just take it out? \$\endgroup\$
    – DjinTonic
    Jul 26, 2021 at 2:41
  • \$\begingroup\$ Thanks, see my reply to Jonah. \$\endgroup\$
    – DjinTonic
    Jul 26, 2021 at 11:19
  • \$\begingroup\$ @DjinTonic great. Have removed the %. Good challenges \$\endgroup\$ Jul 26, 2021 at 12:19

Charcoal, 170 bytes

≔E⁷⟦⟧εFײ⁰φ«≔Eε⁰ζ≔⁰δ≔⁰ηW№ζ⁰«≔⟦⟧θF¹³⊞θ‽⁻E⁵²μθ≧|ΣX²θη≦⊕δ≔↨⁻⊖X²¦⁵³η⁸¹⁹²θFΦ⁷‹§ζλ⎇﹪λ²⁼¹Σ…θ⊘⁺³λ›⊗№θ⁰λ§≔ζλδ»F⁷⊞§εκ§ζκ⊞υ∧¬⊙241536‹§ζIκ§ζλ¹⁰⁰»Eε⪫⟦⊕κ⟦∕÷⁺×χΣι⊘LιLιχ⌊ι⌈ι⟧⟧ ﹪%.1f∕ΣυLυ

Try it online! Link is to verbose version of code. Note: TIO link limited to 200 trials as 20,000 is too slow. +1 byte if you want to output a % sign. Explanation:


Start with an array of 7 empty lists of counts needed to reach the goal.


Loop 20,000 times.


Start with no goals found yet.


Start with no deals yet.


Start with no cards yet.


Repeat until all goals have been found.


Deal 13 different cards at random.


Convert the cards into a bitmask and mark them as having been seen for this trial.


Increment the count for each trial.


Find the suits for which all of the cards have now been seen.


For each goal, mark it as satisfied if it is now but wasn't before. The flag is actually the count of deals for this trial so far.


Push the counts to the lists.


Also keep track of whether this trial's results are in the desired order.


Format the averages as desired.


Format the percentage of trials in the desired order. Sample outputs (from TIO):

1 [7.6, 5, 14]  [7.8, 4, 16]  [7.8, 4, 14] 
2 [11.8, 6, 27] [11.9, 5, 33] [12.3, 5, 34]
3 [10.1, 6, 16] [10.0, 6, 17] [10.0, 6, 16]
4 [14.0, 8, 31] [14.4, 6, 33] [14.0, 7, 34]
5 [12.2, 8, 21] [12.6, 7, 22] [12.7, 7, 21]
6 [15.0, 8, 31] [16.1, 9, 35] [15.4, 7, 37]
7 [16.0, 8, 31] [17.2, 9, 35] [16.3, 9, 37]
  53.0          48.0          51.0         

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.