Question: No Pairs Allowed You have a boutique that specializes in words that don't have adjacent matching characters. Bobby, a competitor, has decided to get


No Pairs Allowed You have a boutique that specializes in words that

don't have adjacent matching characters. Bobby, a competitor, has decided to get

out of the word business altogether and you have bought his inventory.

Your idea is to modify his inventory of words so they are

No Pairs Allowed You have a boutique that specializes in words that don't have adjacent matching characters. Bobby, a competitor, has decided to get out of the word business altogether and you have bought his inventory. Your idea is to modify his inventory of words so they are suitable for sale in your store. To do this, you find all adjacent pairs of matching characters and replace one of the characters with a different one. Determine the minimum number of characters that must be replaced to make a saleable word. For example, you purchased words = [add, boook, break]. You will create an array with your results from the tests. Change d in add, change o in boook and no change is necessary in break. The return array result = [1,1,0]. Function Description Complete the function minimalOperations in the editor below. The function must return an array of integers, each result[i] being the minimum operations needed to fix word[i]. Constraints 1 ns 100 2 words[i] = 105 Each character of words[i] e ascii[a-z). Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains an integer n, the size of the array words. Each of the next n lines contains a string words[i]. Sample Case 0 Sample Input 0 5 ab aab abb abab abaaaba Sample Output 0 0 1 1 0 1 Explanation 0 word = "ab" is already salable so result[0] = 0. word - "aab" is not salable. We can replace word[0] = 'a' with 'g' to get the string "gab", so result[1] - 1. word = "abb" is not salable. We can replace word[2] = 'b' with 'c' to get the string "abc", so result[2] = 1. word = "abab" is already salable so result[3] = 0. word = "abaaaba" is not salable. We can replace word[3] = 'a' with 'b' to get the string "abababa" and result[4] = 1. We then return result = [0, 1, 1, 0, 1). YOUR ANSWER For help on how to read input and write output in Python 3, click here. Click here to know more about handling STDIN and STDOUT in other languages. Sample Problem: Write a program that adds two numbers prints the sum to STDOUT. Read the input from STDIN. The first line of your input will contain an integer (N) that tells you how many more lines there are in the input. Each of the subsequent N lines contain 2 integers). You need to print the sum of each pair on a separate line of STDOUT. Sample Input: 3 15 3 10 999 -34343 Sample Output: 6 13 -33344 SOLUTION CODE nint (input()) for X in range(n): a, b = map(int, input().strip().split()) print (a + b) Draft saved 02:04 pm 1#!/bin/python3. 10 11 # 12 # Complete the 'minimal operations' function below. 13 # 14 14 #The function is expected to return an INTEGER_ARRAY. #The function accepts STRING_ARRAY words as parameter. 15 15 16 16 17 18 19 20 21 if # # def minimalOperations (words): # Write your code here name ===_____main_ Original Code Python 3 @

Step by Step Solution

3.60 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!