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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| def time_move(m,s,move):
if (s<50 and move==10) or (s>9 and move == -10):
s=s+move
elif s<10 and move == -10:
if m == 0 :
m=0
s=0
else:
m-=1
s+=50
elif s>49 and move == 10:
m+=1
s-=50
m=str(m)
s=str(s)
if len(m)==1:
m='0'+m
if len(s)==1:
s='0'+s
return m, s
def solution(video_len, pos, op_start, op_end, commands):
answer = ''
m, s=pos.split(":")
op_start_int = op_start.split(":")[0] + op_start.split(":")[1]
op_end_int = op_end.split(":")[0] + op_end.split(":")[1]
video_int = video_len.split(":")[0] + video_len.split(":")[1]
for c in commands:
if op_start_int <= m+s and op_end_int >= m+s:
m, s=op_end.split(":")
if c == 'next' and m+s < video_int:
m, s = time_move(int(m), int(s), 10)
elif c == 'prev':
m, s = time_move(int(m), int(s), -10)
if op_start_int <= m+s and op_end_int >= m+s:
m, s=op_end.split(":")
if m+s > video_int :
return video_len
answer = m+":"+s
return answer
|