История изменений
Исправление alfix, (текущая версия) :
import random
g,s = 0,1
box = [[g,g],[s,g],[s,s]]
for t in ['1/3','1/2','2/3']:
result = {True:0,False:0}
while result[True] + result[False] < 1000:
a = random.choice(box)
if g in a or t != '1/2':
while True:
i = random.randint(0,len(a)-1)
if a[i] == g:
result[a[1-i]==g] += 1
break
elif t != '1/2':
if t == '1/3': result[False] += 1
break
print(t + ': ' + str(result))
1/3: {False: 681, True: 319}
1/2: {False: 497, True: 503}
2/3: {False: 328, True: 672}
Исправление alfix, :
import random
g,s = 0,1
box = [[g,g],[s,g],[s,s]]
for t in ['1/3','1/2','2/3']:
result = {True:0,False:0}
while result[True] + result[False] < 1000:
a = random.choice(box)
if g in a or t != '1/2':
while True:
i = random.randint(0,len(a)-1)
if a[i] == g:
result[a[1-i]==g] += 1
break
else:
if t == '1/3': result[False] += 1
if t != '1/2': break
print(t + ': ' + str(result))
1/3: {False: 681, True: 319}
1/2: {False: 497, True: 503}
2/3: {False: 328, True: 672}
Исходная версия alfix, :
import random
g,s = 0,1
box = [[g,g],[s,g],[s,s]]
for t in ['1/3','1/2','2/3']:
result = {True:0,False:0}
while result[True] + result[False] < 1000:
a = random.choice(box)
if g in a or t != '1/2':
while True:
i = random.randint(0,len(a)-1)
if a[i] == g:
result[a[1-i]==g] += 1
break
else:
if t == '1/3': result[False] += 1
if t != '1/2': break
elif t == '2/3':
result[False] += 1
print(t + ': ' + str(result))
1/3: {False: 681, True: 319}
1/2: {False: 497, True: 503}
2/3: {False: 328, True: 672}