Imagine that line of chars is in fact two rows. Upper row - dots - represents hours (24 hour system), while lower - commas - represents minutes. One character can represent hour, minute or both - whenever it's possible.
At first probably you'd have to convert minutes since midnight to hours and minutes.
The result is the string showing current time in "dot format". The dot count (apostrophe counts here as a dot and will be called so!) is the hour count since midnight and comma count is minutes count. I'll show a few examples to make it clear.
- (Remark) hh:mm -
- (Only hours) 05:00 -
- (Only minutes) 00:08 -
- (hours < minutes) 03:07 -
- (hours > minutes) 08:02 -
- (hours = minutes) 07:07 -
- (the start of the day) 00:00 -
Notice that "both" character can be used max 23 times - for 23:xx, where xx is 23 or more.
If character have to (see rule 5.) be escaped in your language, you could changed it to one of alternatives. If said alternatives aren't enough, you may use other symbols - but keep it reasonable. I just don't want escaping to be a barrier.
;(semicolon) - marker for both hours and minutes (alt:
'(apostrophe) - marker for hours (alt:
,(comma) - marker for minutes (alt:
- The code with the least amount of bytes wins!
- You have to use both symbol whenever it's possible. For 02:04 the result can't be
;',,,. It have to be
- Input - can be script/app parameter, user input (like readline) or variable inside code
3.1. If the variable inside code is used, then its lenght have to be the longest possible. It's
1439(23:59), so it would look like
- The common part which is symbolized by "both" character (12 in 12:05, 3 in 03:10) must be placed on the beginning of the string
- Symbols can be replaced to alternatives only if they would have to be escaped in your code.
- Input is given in minutes after 00:00. You can assume that this is a non-negative integer.
Input: 300 Output: ''''' Input: 8 Output: ,,,,,,,, Input: 187 Output: ;;;,,,, Input: 482 Output: ;;'''''' Input: 427 Output: ;;;;;;; Input: 0 Output: (empty)