You are viewing a single comment's thread. Return to all comments →
def timeInWords(h, m): dict1={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten',11:'eleven',12:'twelve', 13: 'thirteen', 14: 'fourteen', \ 15: 'quarter', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen',20:'twenty',21:'twenty one',22:'twenty two',23:'twenty three', 24:'twenty four',25:'twenty five',26:'twenty six', 27:'twenty seven', 28:'twenty eight', 29:'twenty nine',30:'half'} st=' past ' if(m>30): h=h+1 m=60-m st=' to ' if(m==1): return dict1[m]+" minute"+st+dict1[h] if(m==00): return dict1[h]+" o' clock" elif(m!=15 and 1<m<30): return dict1[m]+" minutes"+st+dict1[h] elif(m==30 or m==15): return dict1[m]+st+dict1[h]
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
The Time in Words
You are viewing a single comment's thread. Return to all comments →