Notice
Recent Posts
Recent Comments
«   2024/04   »
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 29 30
Tags
more
Archives
Today
Total
관리 메뉴

CHIqueen

[Intro] isLucky 본문

프로그래밍/CodeSignal

[Intro] isLucky

CHIqueen 2020. 3. 11. 13:33
def isLucky(n):
    return sum(int(i) for i in str(n)[:len(str(n))//2]) == sum(int(i) for i in str(n)[len(str(n))//2:])

str로 만들어준다음에 슬라이싱으로 반 잘라 합이 같은지 비교했다.

'프로그래밍 > CodeSignal' 카테고리의 다른 글

[Intro] reverseParenthese  (0) 2020.03.11
[Intro] Sort by Height  (0) 2020.03.11
[Intro] commonCharacterCount  (0) 2020.03.11
[Intro] All Longest Strings  (0) 2020.03.11
[Intro] matrixElementsSum  (0) 2020.03.11
Comments