Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- VALID_CHARS = "0123456789abcdef"
- # Defined number of payouts due to winning bets
- iterations = int(input("Number of payouts: "))
- # Number of characters in sequence that need to be correct
- count = int(input("Chars in sequence: "))
- # Amount of coins that user needs to pay for one bet
- pay = int(input("Stake per bet: "))
- # Multiplier for payed coins per bet in case of a win
- multiplier = int(input("Winning multiplier: "))
- print("\n")
- choice = "".join(random.choices(VALID_CHARS, k=count))
- total_earned = 0
- total_payout = 0
- all_tries = 0
- for a in range(1, iterations + 1):
- tries = 0
- while True:
- total_earned += pay
- tries += 1
- combination = "".join(random.choices(VALID_CHARS, k=count))
- if choice == combination:
- all_tries += tries
- total_payout += pay * multiplier
- print(f"[{a}]", "Found after", tries, "tries")
- break
- chance = 1
- for i in range(count):
- chance *= 1 / len(VALID_CHARS)
- chance *= 100
- print("\n")
- print("Statistical probability to win:", f"{chance:.4f}", "%")
- print("Calculated probability to win: ", f"{iterations / all_tries * 100:.4f}", "%")
- print("\n")
- print("Total tries: ", all_tries)
- print("Average tries:", all_tries / iterations)
- print("\n")
- print("Earned: ", total_earned, "Coins")
- print("Payed: ", total_payout, "Coins")
- print("Winnings: ", total_earned - total_payout, "Coins")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement