45
6
Your task is to create a program that is to mimic Big Ben (Twitter).
Task
Whenever a new hour has begun (according to your computer's local time or UTC), you have to output BONG
repeated hour
times (with a space between the words). For example, when it's 3 o' clock, you have to output BONG BONG BONG
. The time format follows the 12-hour time format, ie after 12 o' clock, we have 1 and not 13. The program/function must run forever.
Example:
don't output stuff inside the brackets
(start: 00:34 for example)
BONG (01:00)
BONG BONG (02:00)
(...)
BONG BONG BONG BONG BONG BONG BONG BONG BONG BONG BONG BONG (12:00)
BONG (01:00 again)
(...)
(it continues forever)
Rules
- Each series of
BONG
s must be separated by a newline - Leading/trailing newlines are allowed
- However leading/trailing spaces are not allowed
- The submission must run forever
- Your output may be printed ±3 seconds from the beginning of the hour
- You may not assume the program to be run at any specific hour
This is code-golf, so the program with the shortest bytecount wins!
6Testing these submissions is going to be fun... :D – FlipTack – 2016-12-25T15:16:59.243
1Can we assume starting the program exactly on midnight? – JAD – 2016-12-25T15:21:53.377
1@JarkoDubbeldam No, the program can be started from any hour – user41805 – 2016-12-25T15:22:30.990
@KritixiLithos Damn, that would've saved a bit. – JAD – 2016-12-25T15:24:44.873
Can you clarify "any hour"? Does that mean that the program can start at ±3 seconds from an exact hour or can be started at any time no matter whether it is a whole hour or not? – ElPedro – 2016-12-25T17:08:50.157
1@ElPedro The program can be started at any time from
00:00
to23:59
– user41805 – 2016-12-25T17:10:01.247@ETHproductions You can use whichever you prefer – user41805 – 2016-12-25T18:47:10.677
3for 12/24 do we print 0 bongs or 12 bongs? – Maltysen – 2016-12-25T22:42:46.227
6+1 for a challenge which isn't easily dominated by dedicated code-golfing languages. – Philipp – 2016-12-25T22:59:13.093
2How should the program behave if the system clock is wound back to before 1859? – Amani Kilumanga – 2016-12-26T06:47:48.557
2@Maltysen You need to print out 12
BONG
s for 12/24 – user41805 – 2016-12-26T09:49:42.3431Does it have to work across summertime changes? – Ben – 2016-12-26T12:12:30.277
1@BenAston No, there is no need to worry about that. – user41805 – 2016-12-26T12:13:28.153
3
For testing one can use LD_PRELOAD hack overriding time functions: https://github.com/vi/timeskew .
– Vi. – 2016-12-26T18:46:56.253TIMESKEW="60 1"
makes minutes flow like seconds.