Nice one. Haven't reviewed the math properly (too lazy) but the python code seems fine (or maybe not - see edit 2).
I also edited your post to put the python script in a spoiler for you, saves some space.
I also thought the 7 card double turn in was more like 93% (again, too lazy to do the math) - not that it matters much, in both cases enough to rely on, but nice to know anyways.
Edit:I modified your script a bit to work for 7 cards, and found that it is more like 94% chance of having no double turn in (ignoring wild cards).
#!/usr/bin/python3
import collections,random
def six_cards():
x1 = [1,1,1,2,2,2]
x2 = [1,1,1,3,3,3]
x3 = [2,2,2,3,3,3]
x4 = [1,1,2,2,3,3]
x5 = [1,1,1,1,1,1]
x6 = [2,2,2,2,2,2]
x7 = [3,3,3,3,3,3]
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)
n = [0]*8
maxiter = int(1e5)
for i in range(maxiter):
l=[]
for j in range(6):
l.append(random.randint(1,3))
n[0] += 1
if compare(l,x1) : n[1] += 1
elif compare(l,x2) : n[2] += 1
elif compare(l,x3) : n[3] += 1
elif compare(l,x4) : n[4] += 1
elif compare(l,x5) : n[5] += 1
elif compare(l,x6) : n[6] += 1
elif compare(l,x7) : n[7] += 1
print(n)
print("P[X1] = %5.2f %% (AAA BB
"%(float(n[1])/n[0]*100))
print("P[X2] = %5.2f %% (AAA CCC)"%(float(n[2])/n[0]*100))
print("P[X3] = %5.2f %% (BBB CCC)"%(float(n[3])/n[0]*100))
print("P[X4] = %5.2f %% (ABC ABC)"%(float(n[4])/n[0]*100))
print("P[X5] = %5.2f %% (AAA AAA)"%(float(n[5])/n[0]*100))
print("P[X6] = %5.2f %% (BBB BB
"%(float(n[6])/n[0]*100))
print("P[X7] = %5.2f %% (CCC CCC)"%(float(n[7])/n[0]*100))
print("probability of any 2 pairs from 6 cards = %5.2f %%"%(float(sum(n)-n[0])/n[0]*100))
def seven_cards():
x1 = [1,1,1,1,1,2,2]
x2 = [1,1,1,1,1,3,3]
x3 = [2,2,2,2,2,1,1]
x4 = [2,2,2,2,2,3,3]
x5 = [3,3,3,3,3,1,1]
x6 = [3,3,3,3,3,2,2]
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)
n = [0]*7
maxiter = int(1e5)
for i in range(maxiter):
l=[]
for j in range(7):
l.append(random.randint(1,3))
n[0] += 1
if compare(l,x1) : n[1] += 1
elif compare(l,x2) : n[2] += 1
elif compare(l,x3) : n[3] += 1
elif compare(l,x4) : n[4] += 1
elif compare(l,x5) : n[5] += 1
elif compare(l,x6) : n[6] += 1
print(n)
print("P[X1] = %5.2f %% (AAA BB
"%(float(n[1])/n[0]*100))
print("P[X2] = %5.2f %% (AAA CCC)"%(float(n[2])/n[0]*100))
print("P[X3] = %5.2f %% (BBB CCC)"%(float(n[3])/n[0]*100))
print("P[X4] = %5.2f %% (ABC ABC)"%(float(n[4])/n[0]*100))
print("P[X5] = %5.2f %% (AAA AAA)"%(float(n[5])/n[0]*100))
print("P[X6] = %5.2f %% (BBB BB
"%(float(n[6])/n[0]*100))
print("probability of no 2 pairs from 7 cards = %5.2f %%"%(float(sum(n)-n[0])/n[0]*100))
seven_cards()
Edit 2:For six cards: What about the case AAA ABC (and likewise cases)?
Nice one. Haven't reviewed the math properly (too lazy) but the python code seems fine (or maybe not - see edit 2).
I also edited your post to put the python script in a spoiler for you, saves some space.
I also thought the 7 card double turn in was more like 93% (again, too lazy to do the math) - not that it matters much, in both cases enough to rely on, but nice to know anyways.
[b]Edit:[/b]
I modified your script a bit to work for 7 cards, and found that it is more like 94% chance of having no double turn in (ignoring wild cards).
[spoiler=Python script]
#!/usr/bin/python3
import collections,random
def six_cards():
x1 = [1,1,1,2,2,2]
x2 = [1,1,1,3,3,3]
x3 = [2,2,2,3,3,3]
x4 = [1,1,2,2,3,3]
x5 = [1,1,1,1,1,1]
x6 = [2,2,2,2,2,2]
x7 = [3,3,3,3,3,3]
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)
n = [0]*8
maxiter = int(1e5)
for i in range(maxiter):
l=[]
for j in range(6):
l.append(random.randint(1,3))
n[0] += 1
if compare(l,x1) : n[1] += 1
elif compare(l,x2) : n[2] += 1
elif compare(l,x3) : n[3] += 1
elif compare(l,x4) : n[4] += 1
elif compare(l,x5) : n[5] += 1
elif compare(l,x6) : n[6] += 1
elif compare(l,x7) : n[7] += 1
print(n)
print("P[X1] = %5.2f %% (AAA BBB)"%(float(n[1])/n[0]*100))
print("P[X2] = %5.2f %% (AAA CCC)"%(float(n[2])/n[0]*100))
print("P[X3] = %5.2f %% (BBB CCC)"%(float(n[3])/n[0]*100))
print("P[X4] = %5.2f %% (ABC ABC)"%(float(n[4])/n[0]*100))
print("P[X5] = %5.2f %% (AAA AAA)"%(float(n[5])/n[0]*100))
print("P[X6] = %5.2f %% (BBB BBB)"%(float(n[6])/n[0]*100))
print("P[X7] = %5.2f %% (CCC CCC)"%(float(n[7])/n[0]*100))
print("probability of any 2 pairs from 6 cards = %5.2f %%"%(float(sum(n)-n[0])/n[0]*100))
def seven_cards():
x1 = [1,1,1,1,1,2,2]
x2 = [1,1,1,1,1,3,3]
x3 = [2,2,2,2,2,1,1]
x4 = [2,2,2,2,2,3,3]
x5 = [3,3,3,3,3,1,1]
x6 = [3,3,3,3,3,2,2]
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)
n = [0]*7
maxiter = int(1e5)
for i in range(maxiter):
l=[]
for j in range(7):
l.append(random.randint(1,3))
n[0] += 1
if compare(l,x1) : n[1] += 1
elif compare(l,x2) : n[2] += 1
elif compare(l,x3) : n[3] += 1
elif compare(l,x4) : n[4] += 1
elif compare(l,x5) : n[5] += 1
elif compare(l,x6) : n[6] += 1
print(n)
print("P[X1] = %5.2f %% (AAA BBB)"%(float(n[1])/n[0]*100))
print("P[X2] = %5.2f %% (AAA CCC)"%(float(n[2])/n[0]*100))
print("P[X3] = %5.2f %% (BBB CCC)"%(float(n[3])/n[0]*100))
print("P[X4] = %5.2f %% (ABC ABC)"%(float(n[4])/n[0]*100))
print("P[X5] = %5.2f %% (AAA AAA)"%(float(n[5])/n[0]*100))
print("P[X6] = %5.2f %% (BBB BBB)"%(float(n[6])/n[0]*100))
print("probability of no 2 pairs from 7 cards = %5.2f %%"%(float(sum(n)-n[0])/n[0]*100))
seven_cards()
[/spoiler]
[b]Edit 2:[/b]
For six cards: What about the case AAA ABC (and likewise cases)?
"Strength doesn't lie in numbers, strength doesn't lie in wealth. Strength lies in nights of peaceful slumbers." ~Maria