Many electronic devices, specially old ones, will show a blinking 12:00 when the time has not been set. The purpose of this challenge is to recreate this.

Specifically, the task is to display 12:00 and --:-- alternatively in an infinite loop.

The period should be 1 second, divided evenly in two periods of 0.5 seconds. Here "1 second" and "evenly" can be interpreted loosely. For example, it is acceptable if the code pauses for 0.5 seconds between displaying the strings, even if the resulting period will then be a little higher than 1 second. An initial pause before displaying the first string is acceptable.

Each new string can be displayed either by replacing the former string or in a new line. Trailing whitespace is allowed, except that if each new string is on a different line there should be no empty lines between consecutive strings.

Shortest code in bytes wins.

• does this count as kolmogorov-complexity? – FlipTack Jan 2 '17 at 12:36
• @FlipTack I think so, but I wasn't sure. Thoughts, anyone? – Luis Mendo Jan 2 '17 at 12:45
• @LuisMendo I don't think so, I think the KG tag is mostly for a fixed string. This has more to it, the waiting and alternating strings. – Rɪᴋᴇʀ Jan 2 '17 at 13:25
• Can submissions wait 0.5 seconds before showing initial output? – FlipTack Jan 2 '17 at 18:20
• IMHO, the statement "Each new string can be displayed either by replacing the former string or in a new line" made this challenge not fun. – Setop Jan 3 '17 at 0:53

# Dart, 103 bytes

import'dart:io';f({i=1}){while(i>0){print(i++%2>0?"12:00":"--:--");sleep(Duration(milliseconds:500));}}


Try it online!

Sometimes I hate how verbose and strongly typed Dart has to be :D

# Japt, 27 bytes

500t@ßÃOq"12:00--:--"ò5 gT°


Try it

500t@ßÃ                         :Run the programme again in 500ms
Oq                       :Clear the output
"12:00--:--"ò5         :Split the string "12:00--:--" into chunks of length 5
gT°     :Get the element at index T (initially 0), postfix incremented

• Not quite real-time output, @LuisMendo; explanation added. Figured the other version wouldn't be valid for that reason, thanks for clarifying. – Shaggy Nov 8 '18 at 14:58

# C (clang), 51 bytes

f(i){puts(i?"12:00":"--:--");usleep(500000);f(!i);}


Try it online!

• This doesn't work. 5e5 is a double. The implicit declaration of usleep will cause Clang to assume it is int usleep(double), and depending on the calling convention, it will either wait for a garbage value or call it with 549606724824 (5e5 interpreted as an integer) which is an EINVAL. – EasyasPi Jan 1 at 18:11
• Suggest 1<<19 instead of 500000 – ceilingcat Jan 2 at 7:13
• @ceilingcat 2^19 doesn't exactly equal 500,000. – Logern Jan 3 at 17:14

# GNU AWK, (until version 5.0.1), 64 bytes

This piece of code prints the strings on a new line. Only works in GNU AWK up to version 5.0.1, while the time extension (module) was not obsolete.

@load"time";BEGIN{for(;;){sleep(.5);print++t%2?"12:00":"--:--"}}


## Clearing the screen with clear command (80 bytes)

This example uses the clear command, not native to Awk.

@load"time";BEGIN{for(;;){sleep(.5);system("clear");print++t%2?"12:00":"--:--"}}


## Clearing the screen with \33[H\33[2J\33[3J (85 bytes)

But don't despair if there is no command to clear the screen on your system. Just hard code it. \33 is the ASCII for Escape in octal.

@load"time";BEGIN{for(;;){sleep(.5);print"\33[H\33[2J\33[3J"(++t%2?"12:00":"--:--")}}


## awk, 3534 bytes (+11 for 12:00 --:--)

{for(;++i;i=i%2)print$(i)"\033[A"}  for loop alternates i's value between 1 and 2. echo feeds the values to the program into fields $1and $2, we then print$(i). Try it:

$echo 12:00 --:-- | awk '{for(;++i;i=i%2)print$(i)"\033[A"}'


Edit: Thanks for the ANSI tip to @F.Hauri.

• Ansi sequence use 1 as default, so the 1 is useless in \033[A. – F. Hauri Jan 3 '17 at 8:31

## C 79 Bytes

f(){while(1){printf("\n12:00");usleep(500000);printf("\n--:--");usleep(500000);}}


so the main would look like int main(){ f(); return 0;}

• Welcome to Programming Puzzles & Code Golf! Just so you know, the downvote was cast automatically by the Community user when you edited your answer. I consider this a bug. – Dennis Jan 3 '17 at 18:43
• You have to write a full program or a function, so you'd have to wrap your code in f(){...} or something. Also, the spec allows printing each output on a separate line, so system("clear"); is not required. – Dennis Jan 3 '17 at 18:45
• You still need the while loop in your submission. Also, you cannot pass a float to usleep. – Dennis Jan 3 '17 at 18:58

# Python 3, 78 bytes

import time;x=0
while 1:x=not x;print("12:00--:--"[x*5:x*5+5]);time.sleep(0.5)


Try it online!