fork download
  1. from random import*
  2. def f(s):
  3. p=c=0;M,L=[],list(s)
  4. for t in L:
  5. if t!=p:M+=c,;p=t
  6. c+=1
  7. L[choice(M)]*=randint(0,2);return''.join(L)
  8.  
  9.  
  10. i='PPCG'
  11. n=10000
  12. p=[]
  13. for j in range(n):p+=f(i),
  14. for o in sorted(set(p),None,len):
  15. print'%-*s : %d%%'%(len(i)+1,o,100*p.count(o)/n)
Success #stdin #stdout 0.04s 11560KB
stdin
Standard input is empty
stdout
PPC   : 10%
PPG   : 11%
PCG   : 11%
PPCG  : 33%
PPCGG : 11%
PPPCG : 11%
PPCCG : 10%