Update counting.py

This commit is contained in:
Daniel
2022-12-14 12:33:24 +02:00
committed by GitHub
parent 8167486da9
commit 83131217f4

View File

@@ -1 +1,20 @@
import random
places = [i for i in range(0, 100)]
last, n = 0, 10000
for i in range(n):
random.shuffle(places)
occupied = [random.randint(0, 99)]
for j in range(1, 100):
last = last + 1 if j == 99 and places[j] not in occupied else last
if places[j] in occupied:
x = random.choice(places)
while x in occupied:
x = random.choice(places)
occupied.append(x)
else:
occupied.append(places[j])
print(last/n)