import random def simulate_channel(text: str, error_rate: float = 0.15) -> str: """ Simulates a noisy 6G wireless channel. It randomly destroys characters based on the error_rate probability. """ if not text: return "" corrupted_message = [] # These are the 'static' symbols that replace your text when the signal drops noise_symbols = "!@#$%^&*~?" for char in text: # Use probability to decide if this specific character survives the transmission if random.random() < error_rate and char != " ": # The signal dropped! Replace the letter with a random noise symbol corrupted_message.append(random.choice(noise_symbols)) else: # The signal survived! Keep the original letter corrupted_message.append(char) # Join the pieces back together into a single string return "".join(corrupted_message)