fork download
  1. import random as rn
  2. def mh(stay=True):
  3. secret = rn.choice('abc')
  4. answer = rn.choice('abc')
  5. if secret == answer:
  6. if stay:
  7. return True
  8. else:
  9. return False
  10. else:
  11. if stay:
  12. return False
  13. else:
  14. lol = ''.join([i for i in 'abc' if i!=answer and i!=secret])
  15. answer = ''.join([i for i in 'abc'.replace(lol,'') if i != answer])
  16. if answer == secret:
  17. return True
  18. return False
  19.  
  20. def test(t=True):
  21. k = 0
  22. for i in range(1, 10000):
  23. if mh(stay=t):
  24. k+=1
  25. return k
  26.  
  27. if __name__=='__main__':
  28. print(test())
  29. print(test(t=False))
Success #stdin #stdout 0.12s 12360KB
stdin
Standard input is empty
stdout
3278
6586