Given time in 24-hour format, convert it to words. 

```
For example:
13:00 = one o'clock 
13:09 = nine minutes past one 
13:15 = quarter past one 
13:29 = twenty nine minutes past one
13:30 = half past one 
13:31 = twenty nine minutes to two
13:45 = quarter to two 
00:48 = twelve minutes to one
00:08 = eight minutes past midnight
12:00 = twelve o'clock
00:00 = midnight

Note: If minutes == 0, use 'o'clock'. If minutes <= 30, use 'past', and for minutes > 30, use 'to'. 

```

More examples in test cases. Good luck!

Difficulty: EASY
Starter code: def solve(time):
	

Solutions:
def solve(time):

	def number(n):
		if n > 20:
			return 'twenty {}'.format(number(n - 20))
		return [None, 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty'][n]
	(hours, minutes) = (int(s) for s in time.split(':'))
	if minutes <= 30:
		direction = 'past'
	else:
		hours = (hours + 1) % 24
		direction = 'to'
		minutes = 60 - minutes
	hour = number((hours + 11) % 12 + 1) if hours else 'midnight'
	if minutes == 0:
		return "{} o'clock".format(hour) if hours else hour
	if minutes == 15:
		return 'quarter {} {}'.format(direction, hour)
	if minutes == 30:
		return 'half past {}'.format(hour)
	return '{} minute{} {} {}'.format(number(minutes), '' if minutes == 1 else 's', direction, hour)


NUMS = [''] + '\none two three four five six seven eight nine ten\neleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty\n'.split()
NUMS += [f'twenty {NUMS[i]}' for i in range(1, 10)]
NUMS += ['thirty']
MINUTES = [f'{x} minutes' for x in NUMS]
(MINUTES[1], MINUTES[15], MINUTES[30]) = ('one minute', 'quarter', 'half')
HOURS = ['midnight'] + NUMS[1:13] + NUMS[1:12]

def solve(time):
	(h, m) = map(int, time.split(':'))
	if h == m == 0:
		return 'midnight'
	if m == 0:
		return f"{HOURS[h]} o'clock"
	elif m <= 30:
		return f'{MINUTES[m]} past {HOURS[h]}'
	else:
		h = (h + 1) % 24
		return f'{MINUTES[60 - m]} to {HOURS[h]}'


d = {0: 'midnight', 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', 30: 'half'}
for i in range(1, 10):
	d[20 + i] = f'{d[20]} {d[i]}'

def solve(time):
	(h, m) = [int(x) for x in time.split(':')]
	to = m > 30
	past_to = 'past to'.split()[to]
	if to:
		h += 1
		m = 60 - m
	h = h % 12 if h != 12 else h
	if m == 0:
		oc = " o'clock" if h else ''
		return f'{d[h]}{oc}'
	s = 's' if m > 1 else ''
	min_word = f' minute{s}' if m not in [15, 30] else ''
	minutes = d[m]
	hour = d[h]
	return f'{minutes}{min_word} {past_to} {hour}'


def solve(time):
	w = ['midnight', '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']
	(h, m) = map(int, time.split(':'))
	(a, b) = (w[12] if h == 12 else w[h % 12], w[h + 1] if h == 11 else w[(h + 1) % 12])
	if m == 0:
		return 'midnight' if h == 0 else a + " o'clock"
	elif m <= 30:
		return w[m] + ' minute past ' + a if m == 1 else 'quarter past ' + a if m == 15 else 'half past ' + a if m == 30 else w[m] + ' minutes past ' + a
	else:
		return 'quarter to ' + b if m == 45 else 'one minute to ' + b if m == 59 else w[60 - m] + ' minutes to ' + b


def solve(time):
	harr = ['midnight', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'midnight']
	marr = ['zero', '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']
	(hour, minute) = list(map(int, time.split(':')))
	if minute == 0:
		if hour == 0:
			return 'midnight'
		return harr[hour] + " o'clock"
	if minute == 15:
		return 'quarter past ' + harr[hour]
	if minute == 45:
		return 'quarter to ' + harr[1 + hour]
	if minute == 30:
		return 'half past ' + harr[hour]
	if minute == 1:
		return 'one minute past ' + harr[hour]
	if minute == 59:
		return 'one minute to ' + harr[1 + hour]
	if int(int(minute) < 30):
		return marr[minute] + ' minutes past ' + harr[hour]
	return marr[60 - minute] + ' minutes to ' + harr[1 + hour]


def solve(time):
	harr = ['midnight', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'midnight']
	marr = ['zero', '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']
	hour = time[:2]
	minute = time[3:]
	if minute == '00':
		if hour == '00':
			return 'midnight'
		return harr[int(hour)] + " o'clock"
	if minute == '15':
		return 'quarter past ' + harr[int(hour)]
	if minute == '45':
		return 'quarter to ' + harr[1 + int(hour)]
	if minute == '30':
		return 'half past ' + harr[int(hour)]
	if minute == '01':
		return 'one minute past ' + harr[int(hour)]
	if minute == '59':
		return 'one minute to ' + harr[1 + int(hour)]
	if int(int(minute) < 30):
		return marr[int(minute)] + ' minutes past ' + harr[int(hour)]
	return marr[60 - int(minute)] + ' minutes to ' + harr[1 + int(hour)]


locale = 'midnight one two three four five six seven eight nine ten eleven twelve thirteen fourteen quarter sixteen seventeen eighteen nineteen twenty'.split()
locale += [f'{locale[-1]} {digit}'.rstrip() for digit in locale[1:10]] + "half, o'clock, minutes, past , to ".split(',')

def solve(time):
	(preposition, (hour, minute)) = (-2, list(map(int, time.split(':'))))
	if minute > 30:
		(preposition, hour, minute) = (preposition + 1, (hour + 1) % 24, 60 - minute)
	if hour > 12:
		hour -= 12
	if not minute:
		return f'{locale[hour]}{locale[-4] * (hour > 0)}'
	return f'{locale[minute]}{locale[-3][:-(minute == 1) or None] * (minute not in (15, 30))}{locale[preposition]}{locale[hour]}'


MINUTES = ('zero,one,two,three,four,five,six,seven,eight,nine,' + 'ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen,' + 'twenty').split(',')
MINUTES.extend([f'twenty {n}' for n in MINUTES[1:10]])
HOURS = ['midnight'] + MINUTES[1:13] + MINUTES[1:12]
QUARTERS = {0: ("{h} o'clock", 0), 15: ('quarter past {h}', 0), 30: ('half past {h}', 0), 45: ('quarter to {h}', 1)}

def solve(time):
	(hh, mm) = list(map(int, time.split(':')))
	h = HOURS[hh]
	h1 = HOURS[(hh + 1) % 24]
	if mm in QUARTERS:
		(template, offset) = QUARTERS[mm]
		if mm == 0 and hh == 0:
			return h
		return template.format(h=h if offset == 0 else h1)
	if mm < 30:
		return f"{MINUTES[mm]} minute{('' if mm == 1 else 's')} past {h}"
	mm = 60 - mm
	return f"{MINUTES[mm]} minute{('' if mm == 1 else 's')} to {h1}"


TRANSLATE = {0: 'midnight', 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: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty'}

def solve(time):

	def hourRepr(hour):
		return TRANSLATE[hour if hour <= 12 else hour % 12]

	def minuteRepr(minute, toNextHour=False):
		relative_minute = minute if not toNextHour else 60 - minute

		def repr(minute):
			if minute < 20 or minute % 10 == 0:
				return TRANSLATE[minute]
			return f'{TRANSLATE[minute // 10 * 10]} {TRANSLATE[minute % 10]}'
		return f"{repr(relative_minute)} minute{('s' if relative_minute > 1 else '')}"
	(hour, minute) = [int(t) for t in time.split(':')]
	if minute == 0:
		return f"{hourRepr(hour)} o'clock" if hour != 0 else hourRepr(hour)
	elif minute == 30:
		return f'half past {hourRepr(hour)}'
	elif minute % 15 == 0:
		return f'quarter past {hourRepr(hour)}' if minute == 15 else f'quarter to {hourRepr(hour + 1)}'
	else:
		return f'{minuteRepr(minute)} past {hourRepr(hour)}' if minute < 30 else f'{minuteRepr(minute, toNextHour=True)} to {hourRepr(hour + 1)}'


NUM = 'midnight one two three four five six seven eight nine\n  ten eleven twelve thir_ four_ fif_ six_ seven_ eigh_ nine_\n  twenty'.replace('_', 'teen').split()
for n in range(1, 10):
	NUM.append(f'twenty {NUM[n]}')

def solve(time):
	(hh, mm) = map(int, time.split(':'))
	if mm > 30:
		hh += 1
	hour = NUM[hh % 12] if hh % 12 else NUM[hh % 24]
	if mm == 0:
		min = ''
	elif mm == 15:
		min = 'quarter past '
	elif mm == 30:
		min = 'half past '
	elif mm == 45:
		min = 'quarter to '
	elif 0 < mm < 30:
		min = f"{NUM[mm]} minute{('s' if mm > 1 else '')} past "
	else:
		min = f"{NUM[60 - mm]} minute{('s' if mm < 59 else '')} to "
	return min + hour + (" o'clock" if mm == 0 and hh > 0 else '')