강의로 돌아가기
조진영

테스트케이스 모두 넣어봤는데도 6,9,12번이 오답입니다..

코드가 좀 지저분하긴 한데..테스트케이스 다 추가해봤는데 다 통과하는데 제출하면 6,9,12번이 계속 오답입니다 ㅠㅠ

작성중인 코드―solution.py
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
1 개의 답변
낙방여우
    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

뭔가 부족해 보이지 않나요?

답변 쓰기
이 입력폼은 마크다운 문법을 지원합니다.