HTHTorTHTH
an anonymous user
·
Python
print('Hello world!')
import matplotlib.pyplot as plt
import random
def simulate_coin_tosses(n_flips):
return ''.join(random.choice('HT') for _ in range(n_flips))
def simulate_betting(sequence):
total_balance = 0
balance_curve = []
bet_on_T = False
bet_on_H = False
for i in range(len(sequence)):
if sequence[i:i+4] == 'HTHT' and not bet_on_T:
total_balance += 10
bet_on_T = True
elif sequence[i:i+4] == 'THTH' and not bet_on_H:
total_balance += 10
bet_on_H = True
if bet_on_T and sequence[i:i+4] == 'HTHT':
total_balance += 10
bet_on_T = False
elif bet_on_H and sequence[i:i+4] == 'THTH':
total_balance += 10
bet_on_H = False
balance_curve.append(total_balance)
return balance_curve
# Simulate 500 coin flips
sequence = simulate_coin_tosses(500)
# Simulate betting based on the sequence
balance_curve = simulate_betting(sequence)
# Plot the total balance curve
plt.plot(balance_curve)
plt.xlabel('Flip Number')
plt.ylabel('Total Balance')
plt.title('Total Balance Curve with Betting Strategy')
plt.show()
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.