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? Jan 2 '17 at 12:36
• @FlipTack I think so, but I wasn't sure. Thoughts, anyone? 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. Jan 2 '17 at 13:25
• Can submissions wait 0.5 seconds before showing initial output? 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. Jan 3 '17 at 0:53

# Q/KDB+, 61 Bytes

s:("12:00";"--:--")
b:1b
.z.ts:{b::not b;show s[b]}
\t 500


Explanation:

s:("12:00";"--:--")


Assign the values we wish to show in a list.

b:1b


Assign a boolean variable to flip between 0 and 1 easily.

.z.ts:{b::not b;show s[b]}


This is a KDB+ function which is invoked in set intervals by the timer function (\t) http://code.kx.com/wiki/Reference/dotzdotts
This executes the code inside the curly braces when \t is set. Show the value in s and then flipping the value of b between 0 and 1.

\t 500


Effectively calls .z.ts every 500ms.

# Pushy, 22 bytes (non-competing)

--:wO12:0&["500oWF


This answer makes use of the two stacks, by flipping between them, printing the characters in turn:

--:    \ Push these characters to stack 1
w       \ Mirror around center, yielding "--:--"
O       \ On the second stack...
12:0  \ Push these characters
&       \ Duplicate the last (for :00)

[        \ Infinitely:
"       \   Print the current stack
500oW   \   Wait 500 milliseconds
F       \   Swap stacks
\ (Implicit end loop)


The oW command is part of a set of experimental commands that postdate the challenge, making this answer non-competing.

# Windows PowerShell, 46 55 bytes

function a{sleep -m 500;cls};for(){"12:00";a;"--:--";a}


### Original Code:

a{sleep -m 500;cls};for(){"12:00";a;"--:--";a}
^ this won't work on other PCs. No idea why.


# Powershell, 46 45 bytes

for(){('12:00','--:--')[$i++%2] sleep -m 500}  • You shouldn't need the ; in the for loop. Link. Nov 5 '18 at 16:58 • Indeed! Thanks. Nov 5 '18 at 17:31 # C# (.NET Core), 138131 127 bytes class H{static int Main(){for(int n=1;;System.Threading.Thread.Sleep(500))System.Console.WriteLine((n^=1)>0?"--:--":"12:00");}}  Try it online! Simple one-liner code. # C# (.NET Core), 127 bytes class H{static int Main(){for(int n=1;;System.Threading.Thread.Sleep(500))System.Console.Write((n^=1)>0?"\r--:--":"\r12:00");}}  Try it online! This code has same length with the code above, it does replace previous line. -7 bytes by using for loops. -4 bytes by using ternary operator. ## Haskell, 79 bytes import System.Posix.Unistd m=(>>usleep 500000).putStrLn g=m"12:00">>m"--:--">>g  m is a helper function that waits half a second before printing its argument. The main function g calls m "12:00", then m "--:--" and then itself again. # S.I.L.O.S, 61 bytes lbla def p printLine p 12:00 wait 500 p --:-- wait 500 GOTO a  Try it online! Unfortunately TIO will just do nothing forever, as it waits until execution to print this. But, if you are eager to test, you can use the GitHub link. ## Arduino CC, 79 bytes void loop(){Serial.print("12:00");delay(500);Serial.print("--:--");delay(500);}  I have no experience with C/C++, so I don't really know how I can golf this. • You could group Serial.print and delay into one separated function. Jan 3 '17 at 7:39 • @F.Hauri, for me it ended up being the same length Jan 3 '17 at 7:43 ## Processing, 69 bytes void draw(){println("12:00");delay(500);println("--:--");delay(500);}  # Python 2, 68 Bytes import time while 1: for i in'12:00','--:--':print i;time.sleep(.5)  # Java, 152 151 bytes (Thanks @AlexRacer) public class c{public static void main(String[] a)throws Exception{int i=1;while(i>0){System.out.println(i++%2<1?"--:--":"12:00");Thread.sleep(500);}}}  Try it here! * (this compiler prints only once a second, couldn't find a better one) • Change while loop to for(int i=0;;){...} and also i++%2==1 to i++%2<1 Jan 3 '17 at 2:18 • Changed this part (i++%2==1), but kept the while. Using your suggestion would even lose some bytes. Thanks for the feedback ;) Jan 3 '17 at 10:11 • You can save a few bytes by limiting this to a function, not a whole program (which is allowed): void f()throws Exception{ ... } – user18932 Jan 3 '17 at 16:56 • You can remove public  in front of class (-7 bytes); remove the space between String[] a (-1 byte), change the while to for so you can put the int inside it: for(int i=1;i>0;){...} (-1 byte). And welcome to PPCG! :) If you haven't checked it out yet, I can recommend looking through Tips for golfing in Java. Jan 6 '17 at 13:01 • Wow, thanks for the tips and for the welcome, @KevinCruijssen! Jan 6 '17 at 16:02 # Dyalog APL, 35 31 bytes Requires ⎕IO←0, which is default on many systems. {5⌽⍵⊣⎕←5↑⍵⊣⎕DL÷2}⍣≡'12:00--:--'  '12:00--:--' a string {...}⍣≡ Repeatedly apply the below anonymous function until two successive results are identical (i.e. never) ÷2 reciprocal of two (one half) ⎕DL Delay that many seconds (returns elapsed time) ⊣ discard that in favor of ⍵ the argument 5↑ take the first five characters ⎕← display with newline ⊣ discard that in favor of 5⌽⍵ the argument cyclically rotated five steps ## QBasic (QB64) 5355 Bytes A$="12:00
B$="--:-- DO ?A$
_DELAY .5
SWAP A$,B$
LOOP


Saved 2 bytes as newline appears to terminate the string definitions.

SWAP makes all the difference. For vanilla QBASIC replace _DELAY with SLEEP S where S is an integer in seconds, but then the frequency is wrong.

• Disappointingly replacing DO..LOOP with 1..GOTO 1 results in the same byte count Jan 3 '17 at 15:07

# C, 77 bytes

#import<windows.h>
i;f(){for(;;i^=1)Sleep(83*printf(i?"\r--:--":"\r12:00"));}

• Just curious, don't you need to write the complete program i.e. include main()? Jan 4 '17 at 3:43
• @6packkid: If not explicitly specified the default is program or function. See this meta discussion: Default for Code Golf: Program, Function or Snippet? Jan 4 '17 at 11:33

# GameMaker Language, 47 bytes

a="12:00"if 9<c mod 20a="--:--"draw_text(0,0,a)


(Assuming a room speed of 20 fps)

# Scala, 100 bytes

object C extends App{var p=1>2;while(2>1){p= !p;println(if(p)"12:00"else"--:--");Thread.sleep(500)}}


## HTML + CSS, 147, 148 142 Bytes

*{font-family:Courier;left 0;background-color:white;position:absolute}@keyframes d{0%,49%{left:0}50%,to{left:-10em}}a{animation:d 1s infinite}
12:00<a>--:--

## Explanation:

Basically, this uses two HTML elements: A text node containing 12:00 and an <a> tag containing --:--.

The selector in the CSS applies to both elements, giving both absolute positioning 0 to the left. This allows both elements to overlap. Then, I gave both elements a monospace font, making each take up equal widths. Finally, I set the background color to white, making sure that the <a> tag hides the text it overlaps.

Then, I use an animation to move the <a> tag offscreen every .5 seconds. To do this, the animation lasts one second, and shows the tag for the first 49%, then hides it for the last 50%.

Oh - finally, Courier is shorter than monospace, saving 3 bytes, but it might not work in all browsers/operating systems.

### Update: +1 Byte

Turns out that Monaco isn't on everyone's computer. changed to using Courier instead at the expense of a byte.

### Update: -6 Bytes

Forgot to remove a bit of whitespace. Oops.

## Non minified code:

* {
position: absolute;
left: 0;
font-family: Courier;
background-color: white;
}
@keyframes d {
0%, 49% {
left: 0
}
50%, to {
left: -10em
}
}
a{animation: d 1s infinite}
12:00<a>--:--

• @LuisMendo I saved 3 bytes by using the font Monaco instead of monospace :P - didn't know about support. I'll change it. Jan 4 '17 at 1:30
• Yes, it works for me now Jan 4 '17 at 1:35
• @LuisMendo cool. thanks a lot for letting me know. Jan 4 '17 at 1:38

while 1 {lmap x 12:00\ --:-- {puts $x;after 500}}  Can be tried on https://goo.gl/8gXPzC Thanks to people on tcl IRC channel. # tcl, 51 while 1 {puts 12:00;after 500;puts --:--;after 500}  Can be tried on https://goo.gl/Hb3sHq # PHP, 48 bytes for(;;usleep(5e5))echo($n^=1)?"
12:00":"
--:--";


Run with -nr.

Replace instead of multiple lines with \r instead of \n (+2 bytes):

for(;;usleep(5e5))echo(\$n^=1)?"\r12:00":"\r--:--";


## R 69 65 61 bytes

y=1;while(1){cat('\r',c('12:00','--:--')[y]);Sys.sleep(.5);y=(y==1)+1}

while(1){cat('\r12:00');Sys.sleep(.5);cat('\r--:--');Sys.sleep(.5)}

f=Sys.sleep;while(1){cat('\r12:00');f(.5);cat('\r--:--');f(.5)}

First time using the f = blah_function() trick, and it saved a few bytes. Used \r to replace existing string.

Fairly simple implementation:

f = Sys.sleep;      #store function for repeated usage
while(1){
cat('\r12:00'); #print 12
f(.5);          #sleep
cat('\r--:--'); #print --
f(.5)           #sleep again
}


# REXX, 60, 54 bytes

d.='--:--'
d.1='12:00'
a=1
do b=0
sleep(.5)
a=\a
say d.a
end


Edit: Turns out that the most naïve solution is even shorter:

do b=0
say '12:00'
sleep(.5)
say '--:--'
sleep(.5)
end


Tested with Regina REXX interpreter; some older implementations may not have the Delay function at all, or it may only support whole seconds.

# Lua, 94 bytes

Unfortunately Lua has no built-in sleep function, so a loop is necessary.

x=1 z=os.clock while 1 do x=-x print(x<0 and"12:00"or"--:--") y=z()+.5 repeat until z()>y end


As a bonus, here's a Windows only one which is 109 bytes and which clears the screen each time:

x=1 z=os.clock while 1 do x=-x print(x<0 and"12:00"or"--:--") y=z()+.5 repeat until z()>y os.execute"cls"end


# Python 2, 92 bytes

import time
t=0
while 1:u=t%2;v='--'*u;w=1-u;print v+'12'*w+':'+v+'00'*w;t+=1;time.sleep(.5)


Try it online!

## Explanation

import time                                   Import the time module
t=0                                           Set a counter, 't', to 0
while 1:                                      Trigger an infinite loop
u = t%2                                   Let 'u' be the remainder of t/2. This will alternate between 0 and 1
w = 1 - u                                 Let 'w' be the opposite of u
v = '--'*u                                Python lets the repetition of strings by multiplying them by an int. Here we are either mulitplying by 1 (no effect) or 0 (turns it to an empty string)
print v + '12'*w + ':' + v + '00'*w       Concatonating 4 strings and printing them. We are using string multiplication again on the '12' and '00'
t += 1                                    Increment the counter variable
time.sleep(0.5)                           Wait half a second


# *><>, 30 bytes

cn"00:"ooo5Sdo"--:--"ooooo5Sdo


Online test.

I feel this is much simpler and more different than redstarcoder's algorithm, and thus I posted it as separate.

Replaces output in-place.

# 8th, 6258 51 bytes

: p . cr .5 sleep ; : f "12:00" p "--:--" p recurse ;


When invoked, the word f will display blinking twelve according the "new line" format. This code leverages "tail-call elimination" implemented in 8th.

The following code (95 bytes long) will let word f display blinking twelve according the "replacing the former string" format:

: p 0 0 con:gotoxy con:print ;
: f con:cls repeat "12:00" p .5 sleep "--:--" p .5 sleep again ;


# ForceLang, 79 bytes

def d datetime.wait 500
def w io.writeln
label 1
w "12:00"
d
w "--:--"
d
goto 1


And here's a version in 125 bytes that actually clears the screen each time and blinks:

set z string.char 8
def d datetime.wait 500
set z z+z+z+z+z
label 1
io.write "12:00"
d
io.write z+"--:--"
d
io.write z
goto 1


# SmileBASIC, 35 bytes

WAIT 30?"12:00
WAIT 30?"--:--
EXEC.


WAIT times are in frames (1/60 second), and EXEC. restarts the program (equivilant to EXEC 0 which runs the code that's in slot 0)

Version that clears the screen and adds 6 bytes:

WAIT 30CLS?"12:00
WAIT 30CLS?"--:--
EXEC.


# Excel VBA (Win, Excel 32 bit Only), 97 Bytes

In a module:

Because VBA's Application.Wait() method cannot handle input for time periods of less than one second, a declaration of the kernel32 sleep method is used for the 500 ms wait period.

Declare Sub Sleep Lib "kernel32" (ByVal s&)


Note: 64-bit versions of VBA (VB7) require a PtrSafe tag after the Declare tag, and changing the ByVal s& call to ByVal s as LongPtr.

In the vbe immediates window:

Do:DoEvents:?"12:00":Sleep 500:?"--:--":Sleep 500:Loop


## PKod, 26 bytes

PKod is an esoteric language that only has one accessible variable

Code:

l12=:o00yyl=-oo=:o=-ooyy<

Explanation:
l - if first char in code, print any NOP chars found
12 - two NOP chars to print
=: - set variable as :
00 - two more NOP chars
o - print variable's corresponding ascii char
y - wait 0.25 seconds
l - if not first char in code, clear the console
=-oo - set variable as - and print twice
< - go back to the start of the code


# 05AB1E, 23 bytes

["12:00--:--"2ä¾è,₄;.W¼


Try it online (sleep doesn't work in TIO, but you can see the output).

Explanation:

[                  # Loop indefinitely:
"12:00--:--"      #  Push string "12:00--:--"
2ä    #  Split into two parts: ["12:00","--:--"]
¾è                #  Index the counter variable in it (with automatic wraparound)
,               #  Output it with trailing newline
₄;                #  Push 1000 halved: 500
.W              #  Sleep that many ms
¼             #  Increase the counter variable by 1