Python/CodeSignal Algorithm(21)
-
[Python] CodeSignal 문제 풀이 (58~60)
58. You are taking part in an Escape Room challenge designed specifically for programmers. In your efforts to find a clue, you've found a binary code written on the wall behind a vase, and realized that it must be an encrypted message. After some thought, your first guess is that each consecutive 8 bits of the code stand for the character with the corresponding extended ASCII code. Assuming that..
2020.04.27 -
[Python] CodeSignal 문제 풀이 (55~57)
55. Given a rectangular matrix containing only digits, calculate the number of different 2 × 2 squares in it. [Example] For the output should be differentSquares(matrix) = 6. Here are all 6 different 2 × 2 squares: 1 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 3 2 3 2 1 [Solution] # def differentSquares(matrix): l = [] total = 0 for i in range(len(matrix) - 1): for j in range(len(matrix[0]) - 1): arr = ..
2020.04.27 -
[Python] CodeSignal 문제 풀이 (52~54)
52. Define a word as a sequence of consecutive English letters. Find the longest word from the given string. [Example] For text = "Ready, steady, go!", the output should be longestWord(text) = "steady". [Solution] # def longestWord(text): l = list() print(ord("a"), ord("z"), ord("A"), ord("Z")) s = "" for i in range(len(text)): if 97
2020.04.14 -
[Python] CodeSignal 문제 풀이 (49~51)
49. Given a string, return its encoding defined as follows: First, the string is divided into the least possible number of disjoint substrings consisting of identical characters for example, "aabbbc" is divided into ["aa", "bbb", "c"] Next, each substring with length greater than one is replaced with a concatenation of its length and the repeating character for example, substring "bbb" is replac..
2020.04.14 -
[Python] CodeSignal 문제 풀이 (46~48)
46. Elections are in progress! Given an array of the numbers of votes given to each of the candidates so far, and an integer k equal to the number of voters who haven't cast their vote yet, find the number of candidates who still have a chance to win the election. The winner of the election must secure strictly more votes than any other candidate. If two or more candidates receive the same (maxi..
2020.03.31 -
[Python] CodeSignal 문제 풀이 (43~45)
43. A string is said to be beautiful if each letter in the string appears at most as many times as the previous letter in the alphabet within the string; ie: b occurs no more times than a; c occurs no more times than b; etc. Given a string, check whether it is beautiful. [Example] For inputString = "bbbaacdafe", the output should be isBeautifulString(inputString) = true. This string contains 3 a..
2020.03.31