{}
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
62
%OFF

Stop copy pasting code you don't actually understand

Build the coding confidence you need to become a developer companies will fight for

Stop copy pasting code you don't actually understand

Become a PRO
Become a PRO
run-icon
main.py
import random # Define the double streets double_streets = { 1: list(range(1, 7)), 2: list(range(7, 13)), 3: list(range(13, 19)), 4: list(range(19, 25)), 5: list(range(25, 31)), 6: list(range(31, 37)), } # Configuration variables sets_width = 12 num_rounds = 10000 low_threshold = 4 high_threshold = 5 # Function to find the double street for a given number, ignoring 0 def find_double_street(num): if num == 0: return None for street_num, street in double_streets.items(): if num in street: return street_num return None # Function to generate a random sample (with possible repeats) def generate_random_sample(): return random.choices(range(37), k=sets_width) # Use random.choices to allow repeats # Track the number of double streets results results = [] zero_count = 0 # Simulate the rounds for _ in range(num_rounds): selected_numbers = generate_random_sample() zero_count += selected_numbers.count(0) hit_streets = {find_double_street(num) for num in selected_numbers if find_double_street(num)} results.append(len(hit_streets)) # Calculate statistics, excluding 0 double streets total_rounds = len(results) counts = {i: results.count(i) for i in range(1, 7)} percentages = {i: (counts[i] / total_rounds) * 100 for i in range(1, 7)} # Calculate the maximum streak for each number of double streets max_streaks = {i: 0 for i in range(1, 7)} current_streaks = {i: 0 for i in range(1, 7)} for result in results: for i in range(1, 7): if result == i: current_streaks[i] += 1 if current_streaks[i] > max_streaks[i] and current_streaks[i] > 1: max_streaks[i] = current_streaks[i] else: current_streaks[i] = 0 # Calculate the percentage and max streak for high_threshold and low_threshold four_or_more = sum(results.count(i) for i in range(high_threshold, 7)) three_or_less = sum(results.count(i) for i in range(1, low_threshold + 1)) percentage_four_or_more = (four_or_more / total_rounds) * 100 percentage_three_or_less = (three_or_less / total_rounds) * 100 max_streak_four_or_more = sum(max_streaks[i] for i in range(high_threshold, 7)) max_streak_three_or_less = sum(max_streaks[i] for i in range(1, low_threshold + 1)) # Print the results in a formatted way print(f"\nStatistics of Double Streets with {num_rounds} sets of {sets_width} numbers ({num_rounds * sets_width} Spins):\n") for i in range(1, 7): print(f"{i} DS | {counts[i]:<5} Sets | {percentages[i]:>5.2f}% | Streak: {max_streaks[i]}") print("\nAdditional Percentages") print("----------------------") print(f"Percentage of rounds with {high_threshold} or more double streets: {percentage_four_or_more:.2f}% | Streak: {max_streak_four_or_more}") print(f"Percentage of rounds with {low_threshold} or less double streets: {percentage_three_or_less:.2f}% | Streak: {max_streak_three_or_less}")
Output