---
# System prepended metadata

title: 舊版

---

# 舊版
import random
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from tqdm.auto import tqdm
people=10000000
max_count=200
record=np.zeros(max_count)
sum=0
damn_count=0
full_count=0
for i in tqdm(range(people)):
  count=0
  A=B=C=0
  while not (A and B and C):
    count+=1
    if count%35==0:
      A+=1
      if B>=2 and C==0:
        B-=1
        C=1
      if C>=2 and B==0:
        C-=1
        B=1
    else:
      result=random.random()
      if result<0.025:
        A+=1
      elif result<0.125:
        B+=1
      elif result<0.225:
        C+=1
  if count==35:
    full_count+=1
  elif count>35:
    damn_count+=1
  record[count]+=1
  sum+=count
plt.figure(figsize=(max_count/2,3))
plt.bar(range(0,max_count*5,5),record,width=0.5,color='black')
plt.xticks(range(0,max_count*5,5))
plt.show()
sum*=(5/people)
print('Avg. diamond: '+str(sum))
print('People who draw 35 times: '+str(full_count/people))
print('People who draw more that 35 times: '+str(damn_count/people))

# ++9
import random
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from tqdm.auto import tqdm
people=10000000
max_count_plus_1=51
record=np.zeros(max_count_plus_1)
sum=0
for i in tqdm(range(people)):
  count=0
  A=B=C=False
  coin=100
  get=0
  while get<3:
    count+=1
    coin+=10
    if count%10==0:
      coin+=30
    result=random.random()
    if result<0.04:
      result=random.random()
      if get==0:
        get+=1
      elif get==1 and result<0.6666666666666667:
        get+=1
      elif get==2 and result<0.3333333333333334:
        get+=1
    if (get*250+coin)>=750:
      break
  record[count]+=1
  sum+=count
plt.figure(figsize=(max_count_plus_1/2,3))
plt.bar(range(0,max_count_plus_1*5,5),record,width=0.5,color='black')
plt.xticks(range(0,max_count_plus_1*5,5))
plt.show()
sum*=(5/people)
print('avg diamond: '+str(sum))

