본문 바로가기
개발/알고리즘

[codility] FrogJmp

by ny0011 2021. 2. 16.
반응형

app.codility.com/programmers/lessons/3-time_complexity/frog_jmp/

 

FrogJmp coding task - Learn to Code - Codility

Count minimal number of jumps from position X to Y.

app.codility.com

나머지가 0보다 크면 1을 더해줌

def solution(X, Y, D):
    # write your code in Python 3.6
    q = (Y-X)//D 
    r = (Y-X)%D
    return q if r == 0 else q+1

'개발 > 알고리즘' 카테고리의 다른 글

[codility] TapeEquilibrium  (0) 2021.02.16
[codility]PermMissingElem  (0) 2021.02.16
[codility] OddOccurrencesInArray  (0) 2021.02.16
[codility] CyclicRotation  (0) 2021.02.16
[codility] BinaryGap  (0) 2021.02.16

댓글