문제 링크입니다: https://programmers.co.kr/learn/courses/33/lessons/1859
COS Pro 2급 Python 모의고사 - 개구리
개구리가 일정한 간격으로 일렬로 놓여있는 징검다리를 건너려고 합니다. 징검다리에는 자연수가 적혀있으며, 개구리는 자신이 밟고 있는 징검다리에 적혀있는 숫자만큼 앞쪽으로 점프해야 합
programmers.co.kr
회사에서 COS Pro 1급을 따면 상금을 준다고 해서 재미로 2급까지 풀어봤습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(stones): | |
cnt = 0 | |
current = 0 | |
n = len(stones) | |
while current < n: | |
current += stones[current] | |
cnt += 1 | |
return cnt |

개발환경: Programmers IDE
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'Python > COS Pro 2급 Python 모의고사' 카테고리의 다른 글
[Programmers] 알파벳 바꾸기 (0) | 2022.05.12 |
---|---|
[Programmers] 키가 K보다 큰 사람 (0) | 2022.05.12 |
[Programmers] 학점 계산 (0) | 2022.05.12 |
[Programmers] 공항 방문객 (0) | 2022.05.12 |
[Programmers] 총점 (0) | 2022.05.12 |