aboutsummaryrefslogtreecommitdiff
path: root/challenge-194/eric-cheung/python/ch-1.py
blob: c8df0f3507a8c10bb2e8a447b69e33f3dee54011 (plain)
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
## strTimeInput = "?5:00"  ## Example 1
## strTimeInput = "?3:00"  ## Example 2
## strTimeInput = "1?:00"  ## Example 3
## strTimeInput = "2?:00"  ## Example 4
## strTimeInput = "12:?5"  ## Example 5
strTimeInput = "12:5?"  ## Example 6

nPos = strTimeInput.find("?")

if nPos == 0:
    for nLoop in [2, 1]:
        nHour = int(str(nLoop) + strTimeInput[1])
        if nHour <= 23:
            print (str(nLoop))
            break
elif nPos == 1:
    for nLoop in [9, 8, 7, 6, 5, 4, 3, 2, 1]:
        nHour = int(strTimeInput[0] + str(nLoop))
        if nHour <= 23:
            print (str(nLoop))
            break
elif nPos == 3:
    for nLoop in [5, 4, 3, 2, 1]:
        nMin = int(str(nLoop) + strTimeInput[4])
        if nMin <= 59:
            print (str(nLoop))
            break
elif nPos == 4:
    for nLoop in [9, 8, 7, 6, 5, 4, 3, 2, 1]:
        nMin = int(strTimeInput[3] + str(nLoop))
        if nMin <= 59:
            print (str(nLoop))
            break