fork(2) download
  1. def get_rate_ur(box, ur, count=10):
  2. p = 1
  3. for i in range(count):
  4. p *= (1 - (ur / (box - i)))
  5.  
  6. return (1-p)
  7.  
  8. def show_rate_ur(box, ur, count=10):
  9. p = get_rate_ur(box, ur, count)
  10. print("[+] Box : %d\t| Remain : %d\t| Count : %d => %.2f%%" % (box, ur, count, round(p * 100, 2)))
  11. return
  12.  
  13.  
  14. show_rate_ur(100, 6, 20)
  15. show_rate_ur(100, 6)
  16. show_rate_ur(89, 5)
  17.  
Runtime error #stdin #stdout #stderr 0.12s 23728KB
stdin
Standard input is empty
stdout
[+] Box : 100	| Remain : 6	| Count : 10 => 47.77%
[+] Box : 89	| Remain : 5	| Count : 10 => 45.70%
[+] Box : 100	| Remain : 6	| Count : 20 => 74.79%
zzz
stderr
Traceback (most recent call last):
  File "./prog.py", line 17, in <module>
EOFError: EOF when reading a line