Enigmatic Code

Programming Enigma Puzzles

Enigma 974: Girls jump first

From New Scientist #2129, 11th April 1998 [link]

Each pony club competing at the gymkhana entered one boy and one girl for the showjumping. In order to determine the order of competition, Mary put all the riders’ names in a hat and drew them out one at a time.

When Mary had drawn precisely half of the names she was surprised to find she had drawn one rider from each club. She calculated that if she did such a draw a thousand times this would only be likely to happen with this number of competing clubs on three occasions (to the nearest whole number). She then realised in amazement that the riders she had drawn in that first half were all the girls.

1. How many clubs were competing?
2. If the number of clubs competing is still as in question 1, on how many occasions (to the nearest whole number) would Mary be likely to draw all the girls first if she carried out the draw five million times?


One response to “Enigma 974: Girls jump first

  1. Jim Randell 7 February 2020 at 8:14 am

    If there are n clubs, then there are 2n competitors.

    The probability of drawing a competitor from a different club on the first n draws is:

    P(n) = ((2n) / (2n)) × ((2n – 2) / (2n – 1)) × ((2n – 4) / (2n – 2)) × … × (2 / (n + 1))
    P(n) = (2^n)(n!)^2 / (2n)!

    And the probability of drawing a girl on the first n draws is:

    Q(n) = (n / 2n) × ((n – 1) / (2n – 1)) × ((n – 2) / (2n – 2)) × … × (1 / (n + 1))
    Q(n) = (n!)^2 / (2n)!

    This Python program runs in 92ms.

    Run: [ @repl.it ]

    from fractions import Fraction as F
    from enigma import irange, factorial, Accumulator, printf
    # probability of drawing one rider from each of n different clubs in the first n draws
    P = lambda n: F(2 ** n * factorial(n) ** 2, factorial(2 * n))
    # find the number of clubs that gives an answer closest to 3/1000
    r = Accumulator(fn=min).accumulate_data_from((abs(F(3, 1000) - P(n)), n) for n in irange(1, 100))
    n = r.data
    printf("(1) n = {n} [p = {p:.10f}]", p=float(P(n)))
    # probability of drawing all the girls in the first n draws
    Q = lambda n: F(factorial(n) ** 2, factorial(2 * n))
    q = Q(n)
    printf("(2) {f:.0f} times [q = {q:.10f}]", f=float(q * 5000000), q=float(q))

    Solution: (1) 11 clubs; (2) 7 times.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: