티스토리 뷰

Codesignal

codesignal 1-3 문제풀이

터보건 2020. 1. 9. 15:32

1. Write a function that returns the sum of two numbers.

  • Example)
    -> 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.

  • Example)
    -> For year = 1905, the output should be centuryFromYear(year) = 20
    -> For year = 1700, the output should be centuryFromYear(year) = 17
def centuryFromYear(year):
    return (year-1) // 100 + 1

3. Given the string, check if it is a palindrome.

  • Example)
    -> For inputString = "aabaa", the output should be checkPalindrome(inputString) = true.
    -> For inputString = "abac", the output should be checkPalindrome(inputString) = false.
    -> For inputString = "a", the output should be checkPalindrome(inputString) = true.
def checkPalindrome(inputString):         
    return inputString == inputString[::-1]

'Codesignal' 카테고리의 다른 글

code signal - 10. commonCharacterCount  (0) 2020.01.29
code signal - 9. All Longest Strings  (0) 2020.01.29
code signal - 8. matrixElementsSum  (0) 2020.01.29
code signal - 7.almostIncreasingSequence  (0) 2020.01.29
codesignal 4-6 문제풀이  (0) 2020.01.14
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함