Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice
- N = 1000000
- def occurences(sub, string):
- return sum(1 for i in range(len(string)) if string.startswith(sub, i))
- seqs = [''.join(choice(['T', 'C']) for _ in range(100)) for _ in range(N)]
- counts = [(seq.count('TC'), occurences('CC',seq)) for seq in seqs]
- alice_wins = sum(b>a for a,b in counts)
- bob_wins = sum(b<a for a,b in counts)
- eq = N - alice_wins - bob_wins
- print(f'Alice: {alice_wins/N*100}%')
- print(f'Bob: {bob_wins/N*100}%')
- print(f'Parità: {eq/N*100}%')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement