lundi 20 mai 2019

Why don't my two sample ever have 0 numbers in common?

I've written a program that samples two lists between 0-9. I then see how many numbers they have in common, and it to a corresponding counter. I've looped this 1000000, but the samples never have 0 numbers in common. Is there something wrong with my code, or am i just extremely unlucky

for _ in range(1000000):

    House_deal = random.sample(range(9), k=5)
    Player_deal = random.sample(range(9), k=5)

    hc = Counter(House_deal)
    pc = Counter(Player_deal)
    common = hc.keys() & pc.keys() #get the intersection of both keys
    counts = 0

    for cel in common:
        counts += min(hc[cel], pc[cel])
    if counts == 0:
        common_0 += 1
    elif counts == 1:
        common_1 += 1
    elif counts == 2:
        common_2 += 1
    elif counts == 3:
        common_3 += 1
    elif counts == 4:
        common_4 += 1
    elif counts == 5:
        common_5 += 1




Aucun commentaire:

Enregistrer un commentaire