Programmers / [PCCP 기출문제] 1번 / 동영상 재생기 / python

2025. 2. 23. 23:21·코딩테스트/programmers (python)

 

 

문제 : 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
'코딩테스트/programmers (python)' 카테고리의 다른 글
  • Programmers / [PCCP 기출문제] 3번 / 충돌위험 찾기 / python
  • Programmers / [PCCP 기출문제] 2번 / 퍼즐 게임 챌린지 / python
  • Programmers / [PCCP 기출문제] 2번 / 석유 시추 / python
  • Programmers / [PCCP 모의고사 1회] 3번 / 붕대 감기 / python
seulll
seulll
개인 공부 / 정리 블로그입니다
  • seulll
    seulll
    seulll
  • 전체
    오늘
    어제
    • 분류 전체보기 (333) N
      • 코딩테스트 (227) N
        • programmers (python) (156)
        • 백준 (python) (69) N
      • 자료구조 | 알고리즘 (14)
      • 개발 | 프로젝트 (19) N
        • Python (4)
        • Java | Spring (7)
        • Android (4)
        • Unity (3)
        • API (4)
      • CS (15)
        • Network (5)
        • SQL (2)
        • OS (4)
      • 데이터 분석 (14)
      • 기타 (13) N
  • 블로그 메뉴

    • 홈
    • 태그
    • 글쓰기
    • 설정
  • 링크

    • GitHub
  • 인기 글

  • 태그

    코딩테스트
    모델 성능 평가
    카카오맵 api
    프로그래머스
    Python
    asterisk
    데이터분석
    대입 표현식
    Greedy
    kakao map api
    백엔드
    train_test_split
    Boxplot
    2 x n 타일링
    카카오맵
    백엔드 개발자 역량
    오차행렬
    solving environment
    confusion matrix
    오블완
    프렌즈4블록
    파이썬
    API
    바다코끼리
    그리디 알고리즘
    야근 지수
    박스플롯
    백엔드 개발자
    티스토리챌린지
    웹크롤링
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
seulll
Programmers / [PCCP 기출문제] 1번 / 동영상 재생기 / python
상단으로

티스토리툴바