Buat bilah Memuat gaya Windows dengan instruksi berikut.
(perhatikan bahwa ini berbeda dari Memuat ... Selamanya )
Output Anda harus dimulai dengan [.... ]
.
Setiap centang, Anda harus menunggu 100 ms, lalu pindahkan setiap titik dengan satu karakter ke kanan. jika titik ada pada karakter kesepuluh, pindahkan ke yang pertama. Perhatikan bahwa Anda harus menghapus layar sebelum mengeluarkan lagi. Outputnya dipesan sebagai berikut:
[.... ]
[ .... ]
[ .... ]
[ .... ]
[ .... ]
[ .... ]
[ ....]
[. ...]
[.. ..]
[... .]
..Lalu itu loop selamanya.
Aturan
- Ini kode-golf , jadi jawaban tersingkat menang.
Aku ragu aku bahkan akan menerima jawaban menang - Harap berikan file gif bilah pemuatan saat beraksi jika memungkinkan.
code-golf
ascii-art
kolmogorov-complexity
animation
Matthew Roh
sumber
sumber
\r
diizinkan, alih-alih membersihkan layar secara harfiah?Jawaban:
V,
171615 byte<esc>
adalah0x1b
.Dan hexdump:
Penjelasan
sumber
i.... <esc>qq:sl 100m<CR>$X|P@qq@q
harus bekerja (<esc>
jelas kunci pelarian dan<CR>
linefeed) (ada 6 spasi setelah 4 titik)gó
fungsinya bermanfaat. Jawaban bagus BTW :)CSS / HTML,
202190186 + 45 =247235231 byteSunting: Disimpan
1214 byte berkat @Luke.sumber
b
?ch
di akhir;0
tidak membutuhkan unit.<x>
menjadi<span>
(dan di dalam CSS juga:x
menjadispan
danx>x
menjadispan>*
)? Itu menghematdisplay:inline-block;
, tetapi biaya hanya 15 byte. Jadi total 6B disimpan.position:absolute;
.PowerShell,
6766 Bytes-1 dengan menggunakan konstruktor yang dipersingkat berkat Beatcracker
mengganti string dengan salinan string di mana karakter terakhir diletakkan di depan karakter yang tersisa, membersihkan layar, mencetaknya, dan kemudian tidur selama 100 ms.
menyimpan banyak byte dengan menggunakan konstruktor for loop daripada membungkus logika di dalam string.
sumber
for
trik lingkaran dan membuat saya membaca kembali about_Join .$s='.'*4+' '*6
.[.... ]
. Anda dapat memperbaikinya tanpa penalti:for($s='.'*4+' '*6){cls;"[$s]";$s=-join($s[,9+0..8]);sleep -m 100}
Python 3 ,
99938583 + 2 ( -u flag ) byte-12 byte terima kasih kepada ovs
-2 byte terima kasih untuk benar-benar manusiawi
Cobalah online!
sumber
flush=True
? Ini bekerja tanpa untuk sayaprint(end='\r[%s]'%s,flush=1)
-u
bendera baris perintah. Pertanyaan terkait SOs[9]+s[:9]
.Windows batch,
201181 byteTernyata menggunakan metode old-school sebenarnya menghemat byte!
catatan:
Harap dicatat bahwa perekam GIF saya melewatkan beberapa bingkai, membuat bilah pemuatan melonjak
:(
sumber
@echo off
dan mengganti do dengando @(echo %%~p&timeout/t 0 >nul&cls)
juga akan berfungsi dan harus menyimpan 11 karakter (200 byte di komputer saya)Mathematica,
6777 Bytes+10 Bytes karena saya lupa tanda kurung.
sumber
Animate
? : |C (gcc) ,
126125124123122121119118117114115 byteYang ini menggunakan bitmask untuk melacak di mana titik-titiknya.
Saya harus menambahkan byte lain karena saya hanya menghasilkan 5 spasi sebelumnya.
Cobalah online!
sumber
Javascript (ES6), 86 byte
sumber
with
. Selalu beri +1 untukwith
!JavaScript (ES6) + HTML,
1048583 byteinput
bukanpre
.Try It
Membutuhkan penutupan
>
on theinput
tag in order to function in a Snippet.sumber
[]
?<input>
instead of<pre>
and thenvalue
instead ofinnerText
?s='.... ';setInterval(f=>{o.value='[${s=s[9]+s.slice(0,9)}]'},100);<input id=o
, maybe someone can improve it (replace quotation mark with `)Noodel,
16151413 bytes[ CỤ‘Ṁ~ððÐ]ʠḷẸḍt]ʠ[Ð.×4¤×6⁺ḷẸḍt]ʠ⁶¤⁴.ȧ[ėÐḷẸḍtTry it:)
How it works
Update
Try it:)
Don’t know why this took me a while to think of. Anyways, this places it at 13 bytes.
sumber
PHP, 67 bytes
no comment
sumber
C#,
162157 bytesor as whole program for 177 bytes
sumber
for(string o="[.... ]";;)
can be golfed tovar o="[.... ]";for(;;)
. Or you can us a port of my Java 7 answer to golf the total some more:()=>{var o=".... "for(;;){o=(o+o).Substring(9,10);System.Console.Write("["+o+"]\n");System.Threading.Thread.Sleep(100);System.Console.Clear();}};
$"[{o}]\n"
System.Console.Write(o)
withSystem.Console.Write(o+"\r")
you can remove theSystem.Console.Clear();
Pure bash, 68
sumber
MATL, 24 bytes
Try it at MATL Online! Or see a gif from the offline compiler:
Explanation
sumber
Jelly,
2827 bytesHow?
sumber
C (gcc),
202198196189969988867977757473 bytesSaved
78 bytes thanks to Digital Trauma.Or, if your system's
stdout
doesn't need to be flushed after every write without a newline:C (gcc), 70 bytes
How it works
usleep(
sleeps for the next return value in microseconds.dprintf(2,
prints to file descriptor 2, orstderr
. This is necessary because whilestdout
is line-buffered (meaning output will not show until it prints a newline),stderr
is character-buffered (all output is shown immediately)."\r
prints a carriage return (clears the current line).[%-10.10s]"
is theprintf
format specifier for a string with exact length 10 (no matter what string provided the output will always be a string with length 10), padded with spaces to the right if necessary. This will be enclosed with brackets.".... ...."
is the loading bar.+i%10
offsets the loading bar by the current index modulo 10. For example, ifi == 3
,i % 10
is equal to 3. Offsetting the loading bar by 3 makes it equal to". ...."
.printf
format specifier, it limits to a length of 10 if necessary and adds spaces to the end if necessary. Therefore, the loading bar will always be between[.... ]
and[. ...]
.sumber
i;f(){for(;;i=++i%10)usleep(7500*dprintf(2,"\r[%-10.10s]",".... ...."-i+10));}
should work.f(i){usleep(dprintf(2,"\r[%-10.10s]",".... ...."+i%10)<<13);f(i+9);}
Java 7,
139124 bytes\r
thanks to @Phoenix.The carriage return
\r
resets the 'cursor' back to the begin of the line, which can then be overwritten. Unfortunately, online compilers nor the Eclipse IDE doesn't support this, so I've added a gif at the end of this answer to show it from Windows Command Prompt.Try it here. (Slightly modified so you won't have to wait for the time-out before viewing the result. Also, the TIO doesn't support carriage returns, so every line is printed without overwriting the previous line.)
Explanation:
Output gif:
sumber
println
withprint
and outputting a carriage return. Might not work in your IDE's terminal, but it would work in any other sane one.\r\n
? How doesSystem.out.print(someString+"\r\n);
clear the console.. It's the same as usingSystem.out.println(someString);
.. It simply goes to the next line, but doesn't remove any previous line printed.. :S\r
, without\n
. That resets the "cursor" to the beginning of the line so printing anything will overwrite that line.Python 2,
8178 bytes-1 byte (noticing I missed use of
%s
when Rod submitted an almost identical Python 3 version at the same time!)-2 bytes (using totallyhuman's idea - replace
s[-1]+s[:-1]
withs[9]+s[:9]
)sumber
\r
overwrites the line and the,
makes it print a tuple rather than a string - I saw it a while back somewhere and have used it before too.sys.stdout.flush()
)Go,
150145132129124 bytes-5 bytes thanks to sudee.
I feel like I don't see enough Go here... But my answer is topping C so... pls halp golf?
Try it online!
sumber
100000000
to10^8
to save 5 bytes.10**8
which also gives an error.1e8
.VBA 32-bit,
159157143141134 BytesVBA does not have a built in function that allows for waiting for time periods less than one second so we must declare a function from
kernel32.dll
32 Bit Declare Statement (41 Bytes)
64 Bit Declare Statement (49 Bytes)
Additionally, we must include a
DoEvents
flag to avoid the infinite loop from making Excel appear as non-responsive. The final function is then a subroutine which takes no input and outputs to the VBE immediate window.Immediate Window function, 93 Bytes
Anonymous VBE immediate window function that takes no input and outputs to the range
A1
on the ActiveSheetOld Version, 109 Bytes
Immediate window function that takes no input and outputs to the VBE immediate window.
Ungolfted and formatted
-2 Bytes for removing whitespace
-30 Bytes for counting correctly
-14 Bytes for converting to immediate window function
Output
The gif below uses the full subroutine version because I was too lazy to rerecord this with the immediate window function.
sumber
a
at the top of the output?a
as is listed above; this is functionally equivalant to the more verbosecall a()
.05AB1E, 23 bytes
Try it online!
Explanation
sumber
Batch,
9998 bytesSaved 1 byte thanks to SteveFest!
(I could remove
\r
from the code, but in the spirit of batch golfing, I won't.)There are four spaces after the first line.
The main logic is modifying the string.
%s:~-1%
is the last character of%s%
and%s:~0,-1%
is all but the last character of%s%
. Thus, we are moving the last character to the front of the string, which rotates the string.sumber
0
in the variable substring can be removedcmder
. Nice job.Ruby,
5756 bytesHeavily influenced by other answers here.
Saved a byte thanks to @manatwork. Also apparently I have trouble counting characters -- I use ST3 and apparently it will include newlines in the count of characters in the line if you're not attentive.
sumber
s
?s
at the beginning of the program as 4.
s and a few spacess[0..8]
→s.chop
Perl, 69 bytes
-3 bytes thanks to @Dom Hastings.
That
select undef,undef,undef,.1
is the shortest way to sleep less than 1 second in Perl, and it takes a lot of bytes...Slightly longer (79 bytes), there is:
sumber
!print
but you need parens so it ends up the same length :/Bash,
939096 bytesview here
couldn't get nested { } in for syntax
sumber
Groovy, 72 bytes
Explaination
sumber
\r
to return the cursor to the start of the line. It appears that at least several answers are doing this. From there, you could delete the *20, saving 3 bytes.Haskell (Windows), 159 bytes
Explanation
Haskell's purity made generating the cycling dot pattern somewhat complex. I ended up creating a nested list comprehension that generated an infinite list of strings in the order they should be output, then went back added the appropriate IO operations.
sumber
Ruby, 61 bytes
If the spec were for the dots to scroll left instead of right, it would save 1 byte because
rotate!
with no arguments shifts the array once to the left.sumber
GNU sed (with exec extension), 64
Score includes +1 for
-r
flag.sumber
c, 100
sumber
stderr
usingdprintf
and not just useprintf
?stderr
is character buffered, whereasstdout
is line buffered. Since I don't want to print any\n
, then withprintf()
I'd have to explicitlyfflush(stdout)
as well as#include <stdio.h>
#include <stdio.h>
to flush STDOUT.fflush(0)
flushes all buffers.main
tof
, that counts.