(Challenge added over 5 years ago.)
A Byte In Time Saves Nine
If your submission fails because one of the tests has no expected output, then please retry your submission. It's seems to be an intermittent problem, and we're looking into it. Thanks.
In this challenge you must draw an analogue clock face, using the time provided to you in 24-hour digital format.
Example time (given on stdin):
o o o o o h o o o m o o
Note that the minutes are rounded down to the nearest 5, so for example the input:
o m o o o o o o h o o o
- The time will be supplied on stdin in the format hh:mm, followed by a single newline. Both hh and mm will be padded with a leading 0 (zero) if they are less than 10.
- The analogue clock face representing that time, subject to the following rules, should be outputted on stdout.
- Each hour mark should be drawn with 'o' (Lower-case O).
- The hour mark representing the hour given in the input should be drawn with an 'h'.
- The hour mark representing the minute given in the input should be drawn with an 'm'.
- If the hour and the minute both fall on the same mark, then you should draw it with an 'x'.
- You should round down the minutes past the hour to the nearest 5 for the purposes of marking it on the clock (so 23 becomes 20, 39 becomes 35).
- Make sure your clock matches the sample results exactly: the spacing before and between each hour mark must be exact, and there must be no trailing whitespace at the end of each line except the newline terminating them. The blank lines should only contain a single newline.
- Trailing whitespace on the last line you output will be ignored.
- Each submission you make will be run 16 times. You will need to pass every test for your submission to be deemed successful. The first eight tests will always have the same input. The remaining eight tests will have random values.
To see the input your program will receive and the expected output for the first eight tests, click the links below :
- Test 1 : 18:00
- Test 2 : 12:00
- Test 3 : 03:03
- Test 4 : 09:01
- Test 5 : 21:08
- Test 6 : 23:59
- Test 7 : 16:24
- Test 8 : 13:06
To see an example of the random values your program will receive in tests 9 through 16, click here. Reload the page to see further examples.
Thanks go to Arpad Ray for suggesting the challenge, and to Ciarán Walsh for typing up the description and continuously pestering me to put it live.