Skip to content

Commit 66599b6

Browse files
authored
[PGS] 340213 동영상 재생기 (Lv.1)
1 parent 011fd0e commit 66599b6

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

박예진/6주차/260203.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def to_sec(t):
2+
return int(t[:2]) * 60 + int(t[3:5])
3+
4+
def solution(video_len, pos, op_start, op_end, commands):
5+
now = to_sec(pos)
6+
ostart = to_sec(op_start)
7+
oend = to_sec(op_end)
8+
video = to_sec(video_len)
9+
10+
# 시작 위치가 오프닝 구간인 경우
11+
if ostart <= now <= oend:
12+
now = oend
13+
14+
for c in commands:
15+
if c == "next":
16+
now += 10
17+
if now > video:
18+
now = video
19+
elif c == "prev":
20+
now -= 10
21+
if now < 0:
22+
now = 0
23+
24+
# 현위치 오프닝 구간이면 끝나는 위치로 이동
25+
if ostart <= now <= oend:
26+
now = oend
27+
28+
return f"{now // 60:02d}:{now % 60:02d}"

0 commit comments

Comments
 (0)