Python/Code_Signal(14)
-
Python #Code_Signal_[ Step 27]
Step 27 Correct variable names consist only of English letters, digits and underscores and they can't start with a digit. Check if the given string is a correct variable name. My solution : Best soulution :
2020.04.07 -
Python #Code_Signal_[ Step 25]
Step 25 Given an array of integers, replace all the occurrences of elemToReplace with substitutionElem. My solution : def arrayReplace(inputArray, elemToReplace, substitutionElem): a=[] for i in inputArray: if i == elemToReplace: a.append(substitutionElem) else: a.append(i) return a Best solution : def arrayReplace(i, e, s): return [x if x!=e else s for x in i] Note This task require to replace ..
2020.03.20 -
Python #Code_Signal_[ Step 24]
Step 24 In the popular Minesweeper game you have a board with some mines and those cells that don't contain a mine have a number in it that indicates the total number of mines in the neighboring cells. Starting off with some arrangement of mines we want to create a Minesweepergame setup. My solution : Best solution : def minesweeper(matrix): r = [] for i in range(len(matrix)): r.append([]) for j..
2020.03.17 -
Python #Code_Signal_[ Step 23]
Step 23 Last night you partied a little too hard. Now there's a black and white photo of you that's about to go viral! You can't let this ruin your reputation, so you want to apply the box blur algorithm to the photo to hide its content. The pixels in the input image are represented as integers. The algorithm distorts the input image in the following way: Every pixel x in the output image has a ..
2020.02.29 -
Python #Code_Signal_[ Step 21, 22]
Step 21 An IP address is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. There are two versions of the Internet protocol, and thus two versions of addresses. One of them is the IPv4 address. Given a string, find out if it satisfies the IPv4 address naming rules. a.b is named network part an..
2020.02.17 -
Python #Code_Signal_[ Step 18 - 20]
Step 18 Given a string, find out if its characters can be rearranged to form a palindrome. ( PALINDROME : A palindrome is a string that reads the same left-to-right and right-to-left ) My solution: def palindromeRearranging(inputString): cntString=[] done=[] for i in inputString: if i in done: continue if inputString.count(i)%2==1: cntString.append(inputString.count(i)) done.append(i) if len(cnt..
2020.02.14