Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 백준 파이썬
- 네트워크 결합
- 범위 기반 for문
- C언어 계산기 프로그램
- 회전 및 자리 이동 연산
- string유형
- IPv4 주소체계
- 프로그래머스 푸드 파이트 대회
- 원형 연결 구조 연결된 큐
- C언어 스택 연산
- auto 키워드
- 입출력 관리자
- l-value참조자
- 문제해결 단계
- 값/참조/주소에 의한 전달
- 유형 변환
- 문자형 배열
- 논리 연산
- 주기억장치
- 괄호 검사 프로그램
- r-value참조자
- 프로그래머스 배열만들기4
- const화
- c언어 괄호검사
- getline()함수
- const l-value참조자
- 알고리즘 조건
- 운영체제 기능
- LAN의 분류
- C언어 덱
Archives
- Today
- Total
chyam
[프로그래머스 Lv1, python] - [PCCP 기출문제] 1번 / 동영상 재생기 본문
https://school.programmers.co.kr/learn/courses/30/lessons/340213
프로그래머스
SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
def change(num): # 초단위로 바꿔주기. 변수를 m,s로 둬야하는데 h,m으로 해버림,,
res = 0
h,m = num.split(":")
res += int(h)*60 + int(m)
return res
def res(num,ans): # 마지막에 "mm:ss"로 바꿔주기.
if num<10:
ans+='0'+str(num)
else:
ans+=str(num)
return ans
def solution(video_len, pos, op_start, op_end, commands):
answer = ''
video_len, pos, op_start, op_end = change(video_len),change(pos),change(op_start),change(op_end)
for cm in commands:
if op_start <= pos < op_end: # 현재 상태가 오프닝 구간이면 건너뛰기
pos = op_end
if cm == "prev": # 이전으로 가기
pos = max(0, pos-10)
else: # 다음으로 가기
pos = min(video_len, pos+10)
if op_start <= pos < op_end: # 현재 상태가 오프닝 구간이면 건너뛰기
pos = op_end
h, m = pos//60, pos%60
# 각각 10보다 작으면 앞에 0붙이기
ans = res(h,answer)
ans += ":"
ans = res(m,ans)
return ans
'프로그래머스 > LV1' 카테고리의 다른 글
[프로그래머스 Lv1, python] - 택배 상자 꺼내기 (0) | 2025.05.21 |
---|---|
[프로그래머스 Lv1, python] - [PCCE 기출문제] 10번/ 공원 (0) | 2025.05.16 |
[프로그래머스 Lv1, python] - 유연근무제 (0) | 2025.05.15 |
[프로그래머스 Lv1,python]-실패율 (0) | 2024.04.13 |
[프로그래머스 Lv1, python]- 추억 점수 (0) | 2024.04.12 |