문제: 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 을 해준후에 다시 캐릭터로 바꾸어 ans_list 안에 넣어준다. (단, 알파벳이 z일때는 +1 을 해주지 않고 바로 'a' 값을 넣어준다.)
3. 모든 알파벳을 다음 알파벳으로 바꾼 ans_list를 정답의 포맷에 맞추어 .join()함수를 써서 string으로 변환후 리턴.
모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]
'CodeSignal > Arcade' 카테고리의 다른 글
CodeSignal [30/60] circleOfNumbers (0) | 2020.05.21 |
---|---|
CodeSignal [29/60] chessBoardCellColor (0) | 2020.05.20 |
CodeSignal [27/60] variableName (0) | 2020.05.18 |
CodeSignal [26/60] evenDigitsOnly (0) | 2020.05.17 |
CodeSignal [25/60] Array Replace (0) | 2020.05.16 |
댓글