Blinking twelve
HTML/CSS, 131 108 106 101 + 18 17 = 149 126 125 123 118 bytes
a{background:#FFF;margin:-5ch;animation:a 1s steps(2,start)infinite}@keyframes a{to{visibility:hidden
<tt>--:--<a>12:00
Edit: Saved 23 bytes thanks to @insertusernamehere. Saved 1 byte by switching from <pre>
to <tt>
. Saved 2 bytes thanks to @darrylyeo. Saved 5 bytes thanks to @DBS.
Octave, 63 62 61 55 bytes
c='--:--00:21';while c=flip(c)disp(c(1:5));pause(.5)end
Saved two bytes thanks to Tom Carpenter! Using a single string instead of two strings in a cell array was shorter.
Explanation:
c='--:--00:21'; % A string where the 5 first characters are --:-- or 12:00 when reversed
while c=flip(c) % A string is always considered true in Octave, so this will loop forever
% while flipping the order of the string each time
disp(c(1:5) % display the 5 first characters of the string c
pause(.5) % Pause 0.5 second
end % End loop
A few bytes saved because Octave doesn't require a colon or semicolon between flip(c)
and disp()
, and between pause(.5)
and end
.
Python2, 80 75 73 69 67 66 bytes
import time
n=0
while[time.sleep(.5)]:print"1-2-::0-0-"[n::2];n^=1
I noticed that my string magic got a little longer than picking the string from an array. Nevermind, figured it out.
Explanation:
I set a counter n to 0, which will be toggled between 0 and 1.
I loop endlessly with the loop
while 1
.I create a string
1-2-::0-0-
, which contains the string12:00
and--:--
interlapped.Starting from the index 0 with a step of 2, we get:
12:00
Starting from the index 1 with a step of 2, we get:
--:--
I use n to make the repeated sequence 0, 1, 0, 1, 0... which will be the starting index of the string.
- Using
n^=1
, in each loop, we get that sequence.^
being the XOR-operator. - If n == 0 -->
n^=1
results in 1 - If n == 1 -->
n^=1
results in 0
- Using
- I print the string, and sleep (
.5
->0.5
) seconds.
@FlipTack saved 4 bytes! --> Put the loop in one line.
@Rod saved 2 bytes! --> n+=1
to n^=1
, thus n%2
to n
.
@xnor saved a byte! --> while 1
--> while[time.sleep(.5)]
.