You are viewing a single comment's thread. Return to all comments →
My python solution:
def timeInWords(h, m):
nums = ["one",'two','three','four','five','six','seven','eight','nine','ten','eleven','tweleve', 'thirteen', 'fourteen',15,'sixteen', 'seventeen', 'eighteen','nineteen','twenty','twenty one','twenty two','twenty three', 'twenty four','twenty five','twenty six','twenty seven','twenty eight', 'twenty nine'] phrases = {0:"o' clock", 15:"quarter past", 30:'half past', 45:"quarter to", } if m==1 and h==1: return 'one minute past one' if m==0: return nums[h-1]+' '+phrases[m] elif m==45: return phrases[m]+' '+nums[h] elif m==15: return phrases[m]+' '+nums[h-1] elif m==30: return phrases[m]+' '+nums[h-1] elif 1<=m<=30: return nums[m-1]+' minutes past '+ nums[h-1] else: k=60-m return nums[k-1]+' minutes to '+nums[h]
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 →
My python solution:
def timeInWords(h, m):