문제 : https://school.programmers.co.kr/learn/courses/30/lessons/340213
나의 풀이
def prevc(cur_time, op_start, op_end):
if cur_time - 10 <= 0:
cur_time = 0
else:
cur_time -= 10
if op_start <= cur_time <= op_end:
cur_time = op_end
return cur_time
def nextc(video_len, cur_time, op_start, op_end):
if cur_time + 10 >= video_len:
cur_time = video_len
else:
if op_start <= cur_time <= op_end:
cur_time = op_end + 10
else:
cur_time += 10
if op_start <= cur_time <= op_end:
cur_time = op_end
return cur_time
def solution(video_len, pos, op_start, op_end, commands):
video_len = int(video_len[0:2]) * 60 + int(video_len[3:5])
pos = int(pos[0:2]) * 60 + int(pos[3:5])
op_start = int(op_start[0:2]) * 60 + int(op_start[3:5])
op_end = int(op_end[0:2]) * 60 + int(op_end[3:5])
if pos >= op_start and pos < op_end:
pos = op_end
for command in commands:
if command == "next":
pos = nextc(video_len, pos, op_start, op_end)
else:
pos = prevc(pos, op_start, op_end)
minutes = pos // 60
seconds = pos % 60
return f"{minutes:02}:{seconds:02}"
'코딩테스트 > programmers (python)' 카테고리의 다른 글
Programmers / [PCCP 기출문제] 3번 / 충돌위험 찾기 / python (0) | 2025.03.24 |
---|---|
Programmers / [PCCP 기출문제] 2번 / 퍼즐 게임 챌린지 / python (0) | 2025.03.16 |
Programmers / [PCCP 기출문제] 2번 / 석유 시추 / python (0) | 2025.02.18 |
Programmers / [PCCP 모의고사 1회] 3번 / 붕대 감기 / python (0) | 2025.02.14 |
Programmers / [PCCP 모의고사 1회] 3번 / 유전법칙 / python (0) | 2025.02.14 |