Setup¶

In [1]:
import math
from math import ceil as mC
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import random

Constants & Functions¶

In [2]:
#Given at least one person survives round R, what is the minimum number of people to start?
def fiddlerMingle(R) :
    
    #Initialize dictionary.
    round_contestants = {}
    #At least one person survives round R means there is 1 group of k people surviving.
    round_contestants[R] = 1
    
    #For each previous value of R...
    for r in range(R-1, 0, -1) :
        
        #The number of survivors is the next round * the number of groups.
        survivors = (r+1)*round_contestants[r+1]
        #The minimum number of contestants for this round is the ceiling of the number of surivors divided by the current round,
        #as that creates complete groups.
        round_contestants[r] = mC(survivors/r)
    
    return(round_contestants)



def ecMingle(C) :
    
    rounds = dict()
    
    #Number of contestants.
    for N in range(1, C+1) : 
        
        #Expected Value.
        ev = 1
        #1 is a factor of every number
        f = 0.1
        
        #Group size.
        for g in range(2, 11) :
            
            #2-10 is a factor of contestants.
            if N/g == int(N/g) :
                f += 0.1
            
            #2-10 is less than number of contestants. 
            elif g < N :
                
                ev += 0.1 * rounds[g*int(N/g)]
                
        
        rounds[N] = ev / (1-f)
    
    return(rounds)

Fiddler¶

In [3]:
fiddlerMingle(38)
Out[3]:
{38: 1,
 37: 2,
 36: 3,
 35: 4,
 34: 5,
 33: 6,
 32: 7,
 31: 8,
 30: 9,
 29: 10,
 28: 11,
 27: 12,
 26: 13,
 25: 14,
 24: 15,
 23: 16,
 22: 17,
 21: 18,
 20: 19,
 19: 20,
 18: 22,
 17: 24,
 16: 26,
 15: 28,
 14: 30,
 13: 33,
 12: 36,
 11: 40,
 10: 44,
 9: 49,
 8: 56,
 7: 64,
 6: 75,
 5: 90,
 4: 113,
 3: 151,
 2: 227,
 1: 454}
In [4]:
for z in range(1, 41):
    print(z, fiddlerMingle(z)[1])
1 1
2 2
3 4
4 6
5 10
6 12
7 18
8 22
9 30
10 34
11 42
12 48
13 58
14 60
15 78
16 82
17 102
18 108
19 118
20 132
21 150
22 154
23 174
24 192
25 210
26 214
27 240
28 258
29 274
30 282
31 322
32 330
33 360
34 372
35 402
36 418
37 442
38 454
39 498
40 510
In [5]:
data = ecMingle(1000)

for i in range(2, 1000) :
    
    if data[i] > data[i-1] + 3 :
        print("For " + str(i-1) + " contestants, the game will last about " + str(round(data[i-1],0))[:-2] + " rounds.")
        print("For " + str(i) + " contestants, the game will last about " + str(round(data[i],0))[:-2] + " rounds.")
        print("")
    
For 71 contestants, the game will last about 38 rounds.
For 72 contestants, the game will last about 41 rounds.

For 119 contestants, the game will last about 65 rounds.
For 120 contestants, the game will last about 70 rounds.

For 143 contestants, the game will last about 81 rounds.
For 144 contestants, the game will last about 84 rounds.

For 179 contestants, the game will last about 101 rounds.
For 180 contestants, the game will last about 106 rounds.

For 209 contestants, the game will last about 120 rounds.
For 210 contestants, the game will last about 123 rounds.

For 239 contestants, the game will last about 137 rounds.
For 240 contestants, the game will last about 142 rounds.

For 251 contestants, the game will last about 146 rounds.
For 252 contestants, the game will last about 149 rounds.

For 279 contestants, the game will last about 162 rounds.
For 280 contestants, the game will last about 165 rounds.

For 359 contestants, the game will last about 208 rounds.
For 360 contestants, the game will last about 218 rounds.

For 419 contestants, the game will last about 248 rounds.
For 420 contestants, the game will last about 252 rounds.

For 449 contestants, the game will last about 267 rounds.
For 450 contestants, the game will last about 270 rounds.

For 479 contestants, the game will last about 284 rounds.
For 480 contestants, the game will last about 288 rounds.

For 503 contestants, the game will last about 299 rounds.
For 504 contestants, the game will last about 304 rounds.

For 539 contestants, the game will last about 321 rounds.
For 540 contestants, the game will last about 326 rounds.

For 559 contestants, the game will last about 334 rounds.
For 560 contestants, the game will last about 337 rounds.

For 599 contestants, the game will last about 357 rounds.
For 600 contestants, the game will last about 361 rounds.

For 629 contestants, the game will last about 375 rounds.
For 630 contestants, the game will last about 379 rounds.

For 719 contestants, the game will last about 428 rounds.
For 720 contestants, the game will last about 437 rounds.

For 791 contestants, the game will last about 476 rounds.
For 792 contestants, the game will last about 479 rounds.

For 809 contestants, the game will last about 486 rounds.
For 810 contestants, the game will last about 489 rounds.

For 839 contestants, the game will last about 503 rounds.
For 840 contestants, the game will last about 513 rounds.

For 899 contestants, the game will last about 543 rounds.
For 900 contestants, the game will last about 548 rounds.

For 959 contestants, the game will last about 579 rounds.
For 960 contestants, the game will last about 583 rounds.

Rohan Lewis¶

2025.01.13¶