def predict_next_size(last_10_sizes): """ Predict the next size (S or B) based on the last 10 sizes. :param last_10_sizes: List of last 10 sizes (each size is 'S' or 'B') :return: Predicted next size ('S' or 'B') """ # Check if the input is valid if len(last_10_sizes) != 10 or not all(size in ['S', 'B'] for size in last_10_sizes): raise ValueError("Input must be a list of exactly 10 sizes, each being 'S' or 'B'.") # Define known patterns and their predictions patterns = { ('S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S'): 'S', ('B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B'): 'B', ('S', 'B', 'S', 'B', 'S', 'B', 'S', 'B', 'S', 'B'): 'S', ('B', 'S', 'B', 'S', 'B', 'S', 'B', 'S', 'B', 'S'): 'B', ('S', 'S', 'B', 'B', 'S', 'S', 'B', 'B', 'S', 'S'): 'B', ('B', 'B', 'S', 'S', 'B', 'B', 'S', 'S', 'B', 'B'): 'S', ('S', 'B', 'B', 'S', 'S', 'B', 'B', 'S', 'S', 'B'): 'S', ('B', 'S', 'S', 'B', 'B', 'S', 'S', 'B', 'B', 'S'): 'B', ('S', 'S', 'S', 'B', 'B', 'B', 'S', 'S', 'S', 'B'): 'B', ('B', 'B', 'B', 'S', 'S', 'S', 'B', 'B', 'B', 'S'): 'S', # Add more patterns as needed } # Check if the last 10 sizes match any known pattern last_10_tuple = tuple(last_10_sizes) if last_10_tuple in patterns: return patterns[last_10_tuple] # If no pattern matches, use the frequency-based heuristic s_count = last_10_sizes.count('S') b_count = last_10_sizes.count('B') if s_count > b_count: return 'S' elif b_count > s_count: return 'B' else: # If both sizes appear equally, predict randomly import random return random.choice(['S', 'B']) # Get the last 10 sizes from the user def get_user_input(): last_10_sizes = [] print("Enter the last 10 sizes (S for small, B for big):") for i in range(10): while True: size = input(f"Size {i+1}: ").strip().upper() if size in ['S', 'B']: last_10_sizes.append(size) break else: print("Invalid input. Please enter 'S' for small or 'B' for big.") return last_10_sizes # Example usage last_10_sizes = get_user_input() predicted_size = predict_next_size(last_10_sizes) print(f"The predicted next size is: {predicted_size}")

Comments