Word Clock
InterviewTime limit0.5sMemory limit512 MB
Convert an hour and minute into the words a word clock shows, using past or to and special phrases for 0, 15, 30, and 45 minutes.
- Level
Easy3 of 10
- Topics
- Implementation, String, Math, Simulation
- Solved
- No attempts yet
Problem
A word clock tells the time using words. Here are some examples.
- 5:00 → five o' clock
- 5:01 → one minute past five
- 5:10 → ten minutes past five
- 5:15 → quarter past five
- 5:28 → twenty eight 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
When the minutes are 0, use "o' clock". When 1 ≤ minutes ≤ 30, use "past". When minutes > 30, use "to".
Given a time, print it in the phrasing a word clock uses.
Input
The first line gives the hour h (1 ≤ h ≤ 12), and the second line gives the minute m (0 ≤ m < 60).
Output
On the first line, print the given time in the phrasing a word clock uses.