Peter can see a clock in the mirror from the place he sits in the office.
When he saw the clock shows 12:22



1
2
3
4
5
6
7
8
9
10
11
12




He knows that the time is 11:38



1
2
3
4
5
6
7
8
9
10
11
12




in the same manner:

05:25 --> 06:35

01:50 --> 10:10

11:58 --> 12:02

12:01 --> 11:59

Please complete the function `WhatIsTheTime(timeInMirror)`, where `timeInMirror` is the mirrored time (what Peter sees) as string.

Return the _real_ time as a string.

Consider hours to be between 1 <= hour < 13.

So there is no 00:20, instead it is 12:20.

There is no 13:20, instead it is 01:20.

Difficulty: introductory

Starter code:

def what_is_the_time(time_in_mirror):
	

Solutions:
def what_is_the_time(time_in_mirror):
    h, m = map(int, time_in_mirror.split(':'))
    return '{:02}:{:02}'.format(-(h + (m != 0)) % 12 or 12, -m % 60)

def what_is_the_time(time_in_mirror):
    array = time_in_mirror.split(":")
    a = int(array[0])
    b = int(array[1])
    
    if a == 11: a = 12
    elif a == 12: a = 11
    else: a = 11 - a
    
    if b == 0: 
        b = 0
        a += 1
    else: b = 60 - b 
    return "{:02}:{:02}".format(a, b)

def what_is_the_time(time_in_mirror):

    CW_HRS = [0,  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    MIRROR = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2,  1, 12, 11]

    if time_in_mirror in ["12:00", "12:30", "06:00", "06:30"]:
        return time_in_mirror
        
    hours, minutes = time_in_mirror.split(':')
    hours, minutes = int(hours), int(minutes)
    hrs = abs(12 - hours) if minutes == 0 else MIRROR[hours]
    mins = 0 if minutes == 0 else 60 - minutes 
    
    return "{:02}:{:02}".format(hrs, mins)

def what_is_the_time(time_in_mirror):
    l=[]
    hour=[]
    minute=[]
    res=[]
    for i in time_in_mirror:
        l.append(i)
    l.pop(2)
    hour.append(l[0])
    hour.append(l[1])
    minute.append(l[2])
    minute.append(l[3])
    hour=''.join(hour)
    minute=''.join(minute)
    hour=int(hour)

    minute=int(minute)
    if(hour<11 and minute!=0):
        hour=11-hour
    elif(hour<11 and minute==0):
        hour=12-hour
    elif(hour==11 and minute!=0):
        hour=12
    elif(hour==11 and minute==0):
        hour=1
    elif(hour==12 and minute!=0):
        hour=11
    elif(hour==12 and minute==0):
        hour=12
    if minute==0:
        minute=0
    else:
        minute=60-minute
    if(hour<10):
        res.append(str(0))
        res.append(str(hour))
    else:
        res.append(str(hour))
    res.append(':')
    if(minute<10):
        res.append('0')
        res.append(str(minute))
    else:
        res.append(str(minute))
    res=''.join(res)
    return res
    #amele styleeee



def what_is_the_time(time_in_mirror):
    hours, minutes = list(map(int, time_in_mirror.split(':')))
    
    if minutes == 0:
        mirrored_hours = 12 - hours
        mirrored_minutes = 0
    else:
        mirrored_hours = (11 - hours) % 12
        mirrored_minutes = 60 - minutes
    if mirrored_hours == 0:
        mirrored_hours = 12
        
    return "{:02d}:{:02d}".format(mirrored_hours, mirrored_minutes)


def what_is_the_time(time):
    h, m = (int(n) for n in time.split(":"))
    return f"{-(h + (m>0)) % 12 or 12:02d}:{-m % 60:02d}"

def what_is_the_time(time_in_mirror: str) -> str:
    h, m = list(map(int, time_in_mirror.split(":")))
    h, m = divmod(720 - m - (h % 12) * 60, 60)
    return f"{h or 12:02d}:{m:02d}"


def what_is_the_time(time):
    a,b = map(int,time.split(':'))
    if 1<=a<=10 and 1<=b<=59 : a, b = 11-a, 60-b
    elif 11<=a<=12 and 1<=b<=59 : a, b = 23-a,60-b
    else : a, b = 12-a,b
    return '{0:>02}:{1:>02}'.format(a or 12,b)

def what_is_the_time(time_in_mirror):
    if not time_in_mirror: return
    x, y = map(int, time_in_mirror.split(':'))
    q, r = divmod(720-60*x-y, 60)
    return "{:02d}:{:02d}".format(q%12 or 12, r)

def what_is_the_time(time_in_mirror):
    hours, minutes = map(int, time_in_mirror.split(':'))
    m_hours, m_minutes = divmod(720 - 60 * hours - minutes, 60)
    return '{:02}:{:02}'.format(m_hours + 12 * (m_hours <= 0), m_minutes)