## 1. Exclusivity: Frontier Cluster > Welcome back, Space Cowboy. The Minutemen have intercepted a cryptic signal from the Frontier Board—a corrupted data stream filled with duplicate entries. Hidden within this mess are critical coordinates that could lead us closer to the legendary Starry Spur. > >Your mission is to sift through this chaotic stream and extract the unique entries. These coordinates must be preserved in the order they were received to maintain their integrity. Any duplicates are remnants of the Board's sabotage—eliminate them swiftly. > >Once you've completed the task, report the refined list to Lena Starling. Time is of the essence, Cowboy—the resistance is counting on you! > Example Input String Input: 7 3 7 9 1 3 5 9 Output String Expected Output: 7 3 9 1 5 ```python= # take in the number n = input() # calculate answer def remove_duplicates(input_string): unique_numbers = [] seen = set() for num in input_string.split(): if num not in seen: unique_numbers.append(num) seen.add(num) return ' '.join(unique_numbers) # process the input to calculate the answer result = remove_duplicates(n) # print answer print(result) ``` ```bash= 23 28 13 100 34 50 89 14 91 42 13 14 70 82 7 21 15 35 15 83 97 66 88 58 17 63 83 13 62 75 7 46 67 66 54 20 19 46 64 40 51 97 95 50 58 72 87 85 41 92 39 62 78 81 9 100 25 32 90 44 56 18 80 56 29 50 81 93 91 76 81 24 18 18 71 66 2 52 24 7 27 41 95 94 33 86 71 57 24 6 24 2 31 68 7 34 82 32 91 70 27 17 36 62 33 55 60 37 55 98 70 78 7 96 24 54 67 70 94 87 34 6 73 70 11 80 40 79 78 2 55 53 79 81 4 76 90 47 67 25 9 37 99 47 67 55 33 41 25 23 32 34 65 72 84 15 51 98 53 84 70 15 73 33 60 9 90 64 66 40 64 2 74 13 86 3 41 100 11 36 7 38 77 85 46 9 2 17 78 17 97 26 91 49 83 16 23 41 27 98 Output: 23 28 13 100 34 50 89 14 91 42 70 82 7 21 15 35 83 97 66 88 58 17 63 62 75 46 67 54 20 19 64 40 51 95 72 87 85 41 92 39 78 81 9 25 32 90 44 56 18 80 29 93 76 24 71 2 52 27 94 33 86 57 6 31 68 36 55 60 37 98 96 73 11 79 53 4 47 99 65 84 74 3 38 77 26 49 16 ``` --- ## 2. Weighted Starfield Stabilizer Weighted Starfield Stabilizer Welcome, Space Cowboy. The resistance has intercepted energy signals from the Frontier Starfield, but they are riddled with weighted anomalies that distort their stability. To analyze the starfield’s stability, you must calculate the maximum stability score. Each energy signal is modified by its corresponding weight, creating a new stability signal: Modified Signal = Signal × Weight Your mission is to identify the maximum stability score for any contiguous subarray of the modified signals. Use your computational skills to ensure the accuracy of your findings! Answer Format: Return a single integer representing the maximum stability score from the starfield. Report your findings to Lena Starling. The resistance depends on your precision to restore balance in the starfield! Example Input Input: signals = [1, -2, 3, -4] weights = [2, 3, -1, 4] Output Output: 48 Explanation: To compute the maximum stability score, follow these steps: Calculate the modified signals: 1 × 2 = 2 -2 × 3 = -6 3 × -1 = -3 -4 × 4 = -16 The modified signals are: [2, -6, -3, -16] Find the maximum product of any contiguous subarray: Subarray [2] : Product = 2 Subarray [-6] : Product = -6 Subarray [2, -6] : Product = -12 Subarray [-3, -16] : Product = 48 The maximum product is 48, which occurs for the subarray [-3, -16] ```python= # Function to calculate the maximum product of any contiguous subarray def max_product_subarray(arr): if not arr: return 0 max_product = arr[0] min_product = arr[0] result = arr[0] for i in range(1, len(arr)): if arr[i] < 0: max_product, min_product = min_product, max_product max_product = max(arr[i], max_product * arr[i]) min_product = min(arr[i], min_product * arr[i]) result = max(result, max_product) return result # Input two arrays as strings signals_str = input().strip() # Example: "1,-2,3,-4" weights_str = input().strip() # Example: "2,3,-1,4" # Convert the input strings to lists of integers # Remove any unwanted characters and split by comma signals = list(map(int, signals_str.strip('[]').split(','))) weights = list(map(int, weights_str.strip('[]').split(','))) # Calculate the modified signals modified_signals = [signal * weight for signal, weight in zip(signals, weights)] # Calculate the maximum stability score max_stability_score = max_product_subarray(modified_signals) # Print the maximum stability score print(max_stability_score) ``` ```bash= Input: [81, -26, 18, 65, -24, 17, 79, 26, 15, -5, -70, 88, 99, 47, -90, -100, 84, 68, 47, -71] [4, 5, 9, 19, 15, 12, 12, 13, 5, 13, 15, 4, 20, 3, 16, 2, 14, 10, 19, 7] Output: 20515358335313379932515165032960491520000000000000 ``` --- ## 3. WordWrangler Welcome, Space Cowboy. The Frontier Archives have transmitted an ancient text encrypted with layers of forgotten languages. The resistance needs your help to decode the most frequently used word in this transmission. Your mission is to count the frequency of each word in the given text, ignoring case and punctuation, and identify the single most common word. If there are multiple words with the same highest frequency, return any one of them. Answer Format: Return the most common word as a single string. Do not include its count in the output. Report the result back to Lena Starling. The resistance is counting on your precision and speed! Example Input Input: "The quick brown fox jumps over the lazy dog. The dog barks at the fox!" Output Output: the ```python= import re from collections import Counter # Input the text as a single string input_text = input() # Example: "The quick brown fox jumps over the lazy dog." # Normalize the text: convert to lowercase and remove punctuation normalized_text = re.sub(r'[^\w\s]', '', input_text.lower()) # Split the text into words words = normalized_text.split() # Count the frequency of each word word_counts = Counter(words) # Find the most common word most_common_word, _ = word_counts.most_common(1)[0] # Print the most common word print(most_common_word) ``` ```bash= Input: snypa csviwm zhfltij fnc snypa ayjnd iava ayjnd kabcu snypa iava kabcu kabcu fnc kabcu iava zhfltij kabcu iava snypa kabcu zhfltij ayjnd kabcu kabcu kabcu ayjnd kabcu zhfltij iava fbg kabcu zhfltij dssek kabcu dssek iava kabcu fhzclrf csviwm fnc fbg kabcu fbg csviwm kabcu fnc csviwm dssek ayjnd iava dssek snypa fnc csviwm kabcu csviwm kabcu csviwm fhzclrf kabcu kabcu iava fhzclrf ayjnd snypa snypa kabcu dssek kabcu kabcu ayjnd fbg fbg csviwm fbg kabcu fnc csviwm kabcu fhzclrf dssek fhzclrf iava fbg kabcu csviwm ayjnd ayjnd kabcu ayjnd zhfltij fbg kabcu ayjnd csviwm kabcu fhzclrf kabcu fhzclrf kabcu snypa fhzclrf dssek fbg kabcu kabcu zhfltij kabcu ayjnd kabcu fnc csviwm kabcu kabcu kabcu iava fhzclrf kabcu snypa kabcu kabcu fhzclrf kabcu kabcu fbg csviwm iava kabcu kabcu dssek iava kabcu zhfltij iava kabcu kabcu kabcu zhfltij zhfltij fnc zhfltij iava zhfltij fhzclrf fhzclrf kabcu iava kabcu iava Output: kabcu ``` --- ## 4. Energy Matrix Activation Greetings, Space Cowboy. The resistance has uncovered the ancient Starry Spur, but its power lies dormant. To activate the energy matrix, you must combine specific energy crystals to reach a precise energy level. Your mission is to calculate the number of ways to combine these crystals to match the required energy level. Each crystal can be used an unlimited number of times, but the combinations must add up to the exact target energy. Report the number of valid combinations to Lena Starling. The fate of the resistance rests in your calculations! Example Input Example 1: Energy Crystals: [1, 2, 3] Target Energy: 4 Example 2: Energy Crystals: [2, 5, 3, 6] Target Energy: 10 Output Example 1 Output: 4 Explanation: There are 4 distinct ways to combine the crystals to reach the target energy level of 4: 1 + 1 + 1 + 1 1 + 1 + 2 2 + 2 1 + 3 Example 2 Output: 5 Explanation: There are 5 distinct ways to combine the crystals to reach the target energy level of 10: 2 + 2 + 2 + 2 + 2 2 + 2 + 2 + 2 + 2 + 2 + 3 2 + 2 + 2 + 6 5 + 5 2 + 3 + 5 Each combination adds up to the target energy level of 10. As before, the order of the crystals does not matter. ```python= # Function to calculate the number of ways to reach the target energy level def count_combinations(crystals, target): # Create a list to store the number of ways to reach each energy level dp = [0] * (target + 1) dp[0] = 1 # There's one way to reach the target of 0 (using no crystals) # Iterate over each crystal for crystal in crystals: # Update the dp array for each energy level from crystal to target for energy in range(crystal, target + 1): dp[energy] += dp[energy - crystal] return dp[target] # Input energy crystals and target energy as strings energy_crystals_str = input().strip() # Input as a string target_energy_str = input().strip() # Input as a string # Convert the input strings to a list of integers and an integer # Remove any unwanted characters and split by comma energy_crystals = list(map(int, energy_crystals_str.strip('[]').split(','))) target_energy = int(target_energy_str) # Calculate the number of ways to reach the target energy level number_of_ways = count_combinations(energy_crystals, target_energy) # Print the number of ways print(number_of_ways) ``` ```bash= Input: [41, 31, 36, 19, 15, 31, 17, 2] 174 Output: 1311 ``` --- ## 5. ConflictCruncher Welcome back, Space Cowboy. The Minutemen have uncovered multiple encrypted data streams from the Frontier Board. These streams contain critical intelligence, but their keys overlap in ways that cause conflicts. Your mission is to merge these conflicting data streams into a single dictionary. When conflicts arise (identical keys), you must apply the Frontier Protocol: retain the value from the second dictionary and discard the conflicting value from the first. Complete this task swiftly and accurately, Cowboy, and report the unified dictionary back to Lena Starling. The fate of the resistance may depend on it! Example Input String Dict input: {'a': 1, 'b': 2, 'c': 3}, {'b': 4, 'd': 5} Output Merged Output: {'a': 1, 'b': 4, 'c': 3, 'd': 5} ```python= # Function to merge two dictionaries according to the Frontier Protocol def merge_dicts(dict1, dict2): # Create a new dictionary to hold the merged result merged_dict = dict1.copy() # Start with the first dictionary merged_dict.update(dict2) # Update with the second dictionary, which will overwrite conflicts return merged_dict # Input two dictionaries as strings dict1_str = input() dict2_str = input() # Convert the input strings to dictionaries dict1 = eval(dict1_str) dict2 = eval(dict2_str) # Merge the dictionaries merged_output = merge_dicts(dict1, dict2) # Print the merged output print(merged_output) ```