Advertisement
Guest User

Wetten auf Anzahl letzter Zeichen des Block Hashes

a guest
Apr 8th, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. import random
  2.  
  3. VALID_CHARS = "0123456789abcdef"
  4.  
  5. # Defined number of payouts due to winning bets
  6. iterations = int(input("Number of payouts: "))
  7. # Number of characters in sequence that need to be correct
  8. count = int(input("Chars in sequence: "))
  9. # Amount of coins that user needs to pay for one bet
  10. pay = int(input("Stake per bet: "))
  11. # Multiplier for payed coins per bet in case of a win
  12. multiplier = int(input("Winning multiplier: "))
  13.  
  14. print("\n")
  15.  
  16. choice = "".join(random.choices(VALID_CHARS, k=count))
  17.  
  18. total_earned = 0
  19. total_payout = 0
  20.  
  21. all_tries = 0
  22. for a in range(1, iterations + 1):
  23.     tries = 0
  24.  
  25.     while True:
  26.         total_earned += pay
  27.         tries += 1
  28.  
  29.         combination = "".join(random.choices(VALID_CHARS, k=count))
  30.         if choice == combination:
  31.             all_tries += tries
  32.             total_payout += pay * multiplier
  33.             print(f"[{a}]", "Found after", tries, "tries")
  34.             break
  35.  
  36. chance = 1
  37. for i in range(count):
  38.     chance *= 1 / len(VALID_CHARS)
  39. chance *= 100
  40.  
  41. print("\n")
  42. print("Statistical probability to win:", f"{chance:.4f}", "%")
  43. print("Calculated probability to win: ", f"{iterations / all_tries * 100:.4f}", "%")
  44. print("\n")
  45. print("Total tries:  ", all_tries)
  46. print("Average tries:", all_tries / iterations)
  47. print("\n")
  48. print("Earned:    ", total_earned, "Coins")
  49. print("Payed:     ", total_payout, "Coins")
  50. print("Winnings:  ", total_earned - total_payout, "Coins")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement