본문 바로가기

전체 글137

CodeSignal [29/60] chessBoardCellColor 문제: Given two cells on the standard chess board, determine whether they have the same color or not. Example: For cell1 = "A1" and cell2 = "C3", the output should be chessBoardCellColor(cell1, cell2) = true. For cell1 = "A1" and cell2 = "H3", the output should be chessBoardCellColor(cell1, cell2) = false. -문제해결 정리- 1. Cell 1 과 Cell 2가 색이 같아질 모든 True 값에 대하여 비교하고, 참이면 Return 아닐경우에는 False Return (Br.. 2020. 5. 20.
CodeSignal [28/60] alphabeticShift 문제: Given a string, your task is to replace each of its characters by the next one in the English alphabet; i.e. replace a with b, replace b with c, etc (z would be replaced by a). Example For inputString = "crazy", the output should be alphabeticShift(inputString) = "dsbaz". -문제해결 정리- 1. inputString에서 각 알파벳의 바꾼 값을 넣어줄 ans_list 를 만들어 준다. 2. inputString안에 있는 각 알파벳을 loop을 돌며 ascii code 값에서 +1 을 해준.. 2020. 5. 19.
CodeSignal [27/60] variableName 문제: 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. Example For name = "var_1__Int", the output should be variableName(name) = true; For name = "qq-q", the output should be variableName(name) = false; For name = "2w2", the output should be variableName(name) = false. -문제 해결 정리-.. 2020. 5. 18.
CodeSignal [26/60] evenDigitsOnly 문제: Check if all digits of the given integer are even. Examples: For n = 248622, the output should be evenDigitsOnly(n) = true; For n = 642386, the output should be evenDigitsOnly(n) = false. -문제 해결 정리- 1. 받는 input 'n' 인자를 string 으로 바꿔서 iterable 할수 있게 만들어 준다. 2. String 으로 바뀌어진 n 인자를 for loop 을 써서 2로 나누어 even 인지 odd 인지 확인해 준다. 3. 만약에 한 숫자라도 even 이 아닌 케이스 발견시, 바로 False 값으로 return. 모든 숫자가 even 일 경우.. 2020. 5. 17.
CodeSignal [25/60] Array Replace 문제: Given an array of integers, replace all the occurrences of elemToReplace with substitutionElem. Example: For inputArray = [1, 2, 1], elemToReplace = 1, and substitutionElem = 3, the output should be arrayReplace(inputArray, elemToReplace, substitutionElem) = [3, 2, 3]. 요약정리 1. Input Array 의 모든 element 들에 대하여 loop을 돈다. 2. Loop을 돌며, 만약 element 가 elemToReplace 와 값이 같으면, substitutionElem으로 교체해준다.. 2020. 5. 16.