HackerRank: The Time in Words

Problem

Given the time in numerals we may convert it into words, as shown below:

5:00 → five o’ clock
5:01 → one minute past five
5:10 → ten minutes past five
5:30 → half past five
5:40 → twenty minutes to six
5:45 → quarter to six
5:47 → thirteen minutes to six
5:28 → twenty eight minutes past five

Write a program which prints the time in words for the input given in the format mentioned above.

Input Format

There will be two lines of input:
H, representing the hours
M, representing the minutes

Constraints
1H<12
0M<60

Output Format

Display the time in words.

Sample Input

5  
47  

Sample Output

thirteen minutes to six

Solution