We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
deftimeInWords(h,m):word=["one","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","twenty one","twenty two","twenty three","twenty four","twenty five","twenty six","twenty seven","twenty eight","twenty nine"]ifm==0:returnword[h]+" o' clock"elifm==15:return"quarter past "+word[h]elifm==30:return"half past "+word[h]elifm==45:return"quarter to "+word[(h+1)%12]elifm==1:return"one minute past "+word[h]elifm==59:return"one minute to "+word[(h+1)%12]elifm<30:returnword[m]+" minutes past "+word[h]else:returnword[60-m]+" minutes to "+word[(h+1)%12]
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Time in Words
You are viewing a single comment's thread. Return to all comments →
Here is my Python solution!