39
7
Introduction
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 -
result
- (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 -
(empty result)
Notice that "both" character can be used max 23 times - for 23:xx, where xx is 23 or more.
Symbols
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:.
)
Additional rules
- 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
'',,,,
, nor;',,,
. 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's1439
(23:59), so it would look liket=1439
- 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.
Test cases
Input: 300
Output: '''''
Input: 8
Output: ,,,,,,,,
Input: 187
Output: ;;;,,,,
Input: 482
Output: ;;''''''
Input: 427
Output: ;;;;;;;
Input: 0
Output: (empty)
Thank you, Adnan for editing my post! This way I'll learn by comparison of my, newbie golf to yours :) – Krzysiu – 2015-12-23T02:28:25.327
3No problem! It is a very good first post and a nice challenge :) – Adnan – 2015-12-23T02:45:23.240
1this looks so good with just semicolons and commas, but apostrophes muck it all up :( – Sparr – 2015-12-23T02:55:20.900
Actually
1439
is23:59
and not1339
. (23 x 60 + 59). – insertusernamehere – 2015-12-23T09:04:07.673Thank all of you for good words! :) @Sparr, yeah, that's the bad point :( Have you idea how it could be replaced? insertusernamehere, of course that's right! Fixed :) – Krzysiu – 2015-12-23T18:33:52.243
3.1 is kind of weird... What does it mean? Does the variable have to be called
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
? – ev3commander – 2015-12-23T21:45:32.313+1 I love this way of represent time! Now I'll try to understand the challenge – edc65 – 2015-12-23T21:49:14.703
If you use
.
for the hours and'
for the minutes and use a newline in between them...... – Magic Octopus Urn – 2017-03-03T20:41:14.543