본문 바로가기

codesignal41

CodeSignal [30/60] circleOfNumbers 문제: Consider integer numbers from 0 to n - 1 written down along the circle in such a way that the distance between any two neighboring numbers is equal (note that 0 and n - 1 are neighboring, too). Given n and firstNumber, find the number which is written in the radially opposite position to firstNumber. Example: Example For n = 10 and firstNumber = 2, the output should be circleOfNumbers(n, fir.. 2020. 5. 21.
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.