[Python] CodeSignal 문제 풀이 (1~3)
2020. 2. 5. 22:17ㆍPython/CodeSignal Algorithm
1. Write a function that returns the sum of two numbers.
For param1 = 1 and param2 = 2, the output should be add(param1, param2) = 3. |
def add(param1, param2):
return param1 + param2
2. Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
|
def centuryFromYear(year):
if((year % 100) == 0):
return year / 100
else:
return (int)((year / 100) + 1)
3. Given the string, check if it is a palindrome.
|
def checkPalindrome(inputString):
return inputString == inputString[::-1]
'Python > CodeSignal Algorithm' 카테고리의 다른 글
[Python] CodeSignal 문제 풀이 (16~18) (0) | 2020.03.12 |
---|---|
[Python] CodeSignal 문제 풀이 (13~15) (0) | 2020.03.12 |
[Python] CodeSignal 문제 풀이 (10~12) (0) | 2020.02.29 |
[Python] CodeSignal 문제 풀이 (7~9) (0) | 2020.02.16 |
[Python] CodeSignal 문제 풀이 (4~6) (0) | 2020.02.16 |