17
1
Problem
One day, you boss walks up to you and tells you he needs to know the time. He still insists after you pointing at the clock directly above you head, and confesses he has a severe case of dyscalculia, which causes him to not even be able to see numbers on a clock. While you're still left wondering how someone unable to see numbers can run a company, he tells you to "do something about it", whatever that is.
Your task is now to create a program or function that, given an input time with hours and minutes (seconds are optional)(hours are 24-based), outputs a readable english sentence, that doesn't contain numbers.
It is not necessary to ouput the seconds.
For example, 08:45:15
should output quarter to nine o'clock AM
Test cases
00:00:00 > twelve night
12:00:00 > twelve noon
06:00:00 > six o'clock AM
18:00:00 > six o'clock PM
06:15:00 > quarter past six o'clock AM
18:45:00 > quarter to seven o'clock PM
11:30:00 > half past eleven o'clock AM
13:22:00 > twentytwo minutes past one o'clock PM
17:43:00 > seventeen minutes to six o'clock PM
00:09:00 > nine minutes past twelve o'clock AM
Rules
Outputting numbers can be both in the form of fortytwo or forty-two, whichever you like best. Standard loopholes are not allowed. Trailing newlines are allowed, but the sentence should be on 1 line.
Input can be in any format you want, for example HH:MM:SS
, HH,MM,SS
, HHMMSS
, HH/MM/SS
, or any variant without seconds, but you should make the input format clear in your answer. It's not needed to output one minute
instead of one minutes
for minutes ranging from 0 trough 30 (0 and 30 included) you should use past
, and for the others you should use to
Because time is relative, shortest code in bytes wins.
1
This looks like a nice challenge, bit I strongly suggest removing the bonuses. Unless you know exactly what you are doing, those are one thing to avoid when writing challenges.
– Denker – 2016-02-05T14:35:31.1001Two more (minor) points: why does it matter how you write
forty-five
when the test cases clearly statequarter to
as the appropriate input format? (just change it to forty-two ;) ) Also, [tag:kolmogorov-complexity] is not an appropriate tag. – Sanchises – 2016-02-05T14:36:58.653@sanchises edited. I misunderstood the kolmogorov tag, and thought it had to do with problems in outputting any string, instead of a given string only. – Dennis van Gils – 2016-02-05T14:41:32.963
1@TimmyD The -70% one was a joke, I didn't imagine anyone would try to translate french in code-golf. However, I feel that having negative size is a decent reward for a perfect french-english translator – Dennis van Gils – 2016-02-05T14:43:27.680
That looks much better, but a few more formatting clarifications are needed. Specifically regarding choosing between "past" and "to" -- from the examples, it sounds like you're wanting to only utilize the numbers
– AdmBorkBork – 2016-02-05T14:43:41.113one
totwenty-nine
, withquarter
replacingfifteen
andhalf
representingthirty
, but that's not clear. Also, for future questions, I heartily recommend the Sandbox to work out the kinks before posting.@TimmyD edited again. I'd also like to apologize, I didn't know about the sandbox. – Dennis van Gils – 2016-02-05T14:51:20.107
No worries! Again, welcome to PPCG! :) – AdmBorkBork – 2016-02-05T14:54:04.523
All of the inputs lie exactly on 5 minute boundaries. Does this imply all inputs will be like this, or that inputs should all be rounded to the nearest 5 minutes, or should single minutes be handled? – Digital Trauma – 2016-02-05T17:21:50.190
@DigitalTrauma updated the question, single minutes should be handled, and
twelve midnight
is indeed more consistent, considering that1 o'clock AM
also has noat
– Dennis van Gils – 2016-02-05T17:36:56.413twelve midnight
ortwelve night
? – Digital Trauma – 2016-02-05T17:40:28.587Just to be sure:
twentytwo
and nottwenty-two
ortwenty two
? – Digital Trauma – 2016-02-05T17:41:29.937@DigitalTrauma I specified both twentytwo and twenty-two are permitted – Dennis van Gils – 2016-02-05T18:48:30.613