https://www.hackerrank.com/challenges/drawing-book/problem?isFullScreen=true
Drawing Book | HackerRank
How many pages does a student need to turn to get to page p?
www.hackerrank.com
가장 빠르게 원하는 페이지에 다가가는 문제인데
첫 장이 0 1 이므로
n과 p를 2로 나눴을때 몫만 확인하면 된다.
def pageCount(n, p):
full_page = n // 2
want_page = p // 2
return min(want_page, full_page-want_page) #앞에서 뒤에서'파이썬 코딩테스트 > 해커랭크' 카테고리의 다른 글
| HackerRank / Circular Array Rotation / Python (0) | 2022.01.07 |
|---|---|
| HackerRank / Picking Numbers / Python (0) | 2022.01.07 |
| HackerRank / Append and Delete / Python (0) | 2022.01.05 |
| HackerRank / Strange Counter / Python (0) | 2022.01.03 |
| HackerRank / Games of Thrones - 1 / Python (0) | 2022.01.02 |