Masalah
Buat kembali UI dari program torrent
Diberikan tanpa input, output sebagai berikut:
+----------+----------+----------+
|a.exe |##########|seeding |
+----------+----------+----------+
|b.exe 10% |# |leeching |
+----------+----------+----------+
|c.exe |##########|seeding |
+----------+----------+----------+
|d.exe 20% |## |leeching |
+----------+----------+----------+
|e.exe |##########|seeding |
+----------+----------+----------+
|f.exe 30% |### |leeching |
+----------+----------+----------+
|g.exe |##########|seeding |
+----------+----------+----------+
|h.exe 40% |#### |leeching |
+----------+----------+----------+
|i.exe |##########|seeding |
+----------+----------+----------+
|j.exe 50% |##### |leeching |
+----------+----------+----------+
|k.exe |##########|seeding |
+----------+----------+----------+
|l.exe 60% |###### |leeching |
+----------+----------+----------+
|m.exe |##########|seeding |
+----------+----------+----------+
|n.exe 70% |####### |leeching |
+----------+----------+----------+
|o.exe |##########|seeding |
+----------+----------+----------+
|p.exe 80% |######## |leeching |
+----------+----------+----------+
|q.exe |##########|seeding |
+----------+----------+----------+
|r.exe 90% |######### |leeching |
+----------+----------+----------+
|s.exe |##########|seeding |
+----------+----------+----------+
|t.exe |##########|seeding |
+----------+----------+----------+
|u.exe |##########|seeding |
+----------+----------+----------+
|v.exe |##########|seeding |
+----------+----------+----------+
|w.exe |##########|seeding |
+----------+----------+----------+
|x.exe |##########|seeding |
+----------+----------+----------+
|y.exe |##########|seeding |
+----------+----------+----------+
|z.exe |##########|seeding |
+----------+----------+----------+
kemajuan program adalah:
b=10% d=20% f=30% h=40% j=50% l=60% n=70% p=80% r=90%
Jumlah #
program lintah adalahprogress/10
sisanya semua seeding
dengan progress bar penuh.
Aturan
- Membiarkan dan mengikuti baris baru diizinkan.
- Ruang depan dan belakang dibolehkan selama tidak mengubah bentuk output.
- stdout dan fungsi untuk output diizinkan.
- Kode terpendek dalam byte menang
code-golf
string
ascii-art
kolmogorov-complexity
LiefdeWen
sumber
sumber
.exe
dari torrent bukan hal terbaik untuk dilakukan, eh?f.exe
tidak dapat menemukan salinannya di tempat lain.f.exe
datang denganf_readme.txt
yang mengatakan, "jalankan sebagai administrator". Kelihatannya mantap.Jawaban:
Arang,
988583 byteSaya pikir menyalin templat akan menyelamatkan saya banyak kode, tetapi semuanya sepertinya bertambah entah bagaimana, meskipun saya berhasil menghemat 13 byte dengan menggunakan satu loop untuk memperbaiki 9 baris lintah. Penjelasan:
(Catatan: Saya sepertinya menemukan bug di Charcoal;
|
adalah karakter ASCII, tetapi juga dihitung sebagai panah untuk keperluanMultiprint
, jadi Anda tidakMultiprint
bisa.)sumber
Perl 5 , 130 byte
Cobalah online!
Saya berharap ada beberapa byte yang bisa di-golf, tapi saya sudah kehabisan inspirasi.
Penjelasan singkat:
$e
berisi garis pemisahan (+----------+----------+----------+
); konstruksinya lurus ke depan (("+"."-"x10)x3 ."+\n"
).Kemudian, saya mengulangi karakter dari
a
kez
:Setiap kali, cetak
"|$_.exe%4s |%-10s|%-9s |\n$e
; ini adalah standarprintf
dengan placeholder untuk string (%s
) dan string kiri-bantalan (%-9s
).jika
$|--&&$@++<9
benar ($|
adalah variabel khusus yang berisi 0 atau 1, dan menurunkannya akan mengubah nilainya), maka persentasenya tidak 100%, dan tiga nilai dalam cetakan adalah"$@0%","#"x$@,leeching
($@0%
sebenarnya hanya$@ . "0" . "%"
- ingat yang$@
ditambahkan sebelumnya) , jika tidak, ketiga nilai tersebut adalah"","#"x10,seeding
).sumber
Python 2 ,
182177 byteTerima kasih kepada @officialaimm karena mencukur 5 byte dengan mengubah format kondisi.
Cobalah online!
sumber
SOGL V0.12 ,
908988 byteCoba Di Sini!
Penjelasan:
sumber
Javascript,
232230228226 byteDemo
Tampilkan cuplikan kode
sumber
s
danp
ke parameter fungsi default, menghilangkan kebutuhan untuk()
s di sekitar fungsi fungsi: Fiddle${x?'leeching ':'seeding '}|
yang berikut ini${x?'leeching':'seeding '} |
:?PHP , 179 byte
tanpa input
Cobalah online!
PHP , 176 byte
dengan input
Cobalah online!
sumber
++
dari++$x&1
(-2), gunakan$y=++$x%4|$z>9?"":++$z."0%"
sebagaiprintf
parameter kedua (-9) dan masukkan$z
sebelumnya:10
(+2)Python 3 , 255 byte
Saya yakin ini dapat dip Golf, segera diperbarui:
Cobalah online!
sumber
leeching |
danseeding |
, tidak bisakah Anda mengubahnya menjadileeching
danseeding
+" |"
?//2*10
adil*5
dan10-(z-96)//2
adil58-z//2
.Ruby , 141 byte
Cobalah online!
sumber
Java (OpenJDK 8) ,
244229228227226224222218217 byteCobalah online!
-2 byte terima kasih kepada @KevinCruijssen!
sumber
leeching
andseeding
are right aligned..format
and0%
, +1! Btw, you can golf your answer some more by starting withs=z
instead, like this:o->{String x="----------+",z="+"+x+x+x,s=z;for(int c=96,p;++c<123;)s+=s.format("%n|%c.exe %3s |%-10s|%-10s|%n"+z,c,(p=(c%2>0|c/2-48>10)?10:c/2-48)<10?p+"0%":"","##########".substring(0,p),p<10?"leeching":"seeding");return s;}
(225 bytes)Python 2,
172170162 bytes-8 bytes thanks to Lynn
Try it online!
sumber
Braingolf,
673655 bytesTry it online!
I've said it before and I'll say it again: Braingolf is bad at ASCII art.
At least this is only 1/3rd of the bytes it would take to actually hardcode the output
sumber
V, 107 bytes
Try it online!
Hexdump:
sumber
Japt, 121 bytes
Try it online!
sumber
Japt, 98 bytes
Doesn't work in the latest version due to a bug that messes up
4î+
,q-p10
, andq|
, but it does work in commitf619c52
. Test it online!sumber
T-SQL, 238 bytes
Procedural solution, formatted:
Everything in the loop (up until the SET) is part of the same PRINT statement, including a line break inside the first string literal.
I'm working on a set-based solution (create and populate a table, then SELECT from it), but I'm not sure if its going to be smaller or not.
sumber
Java 8,
271263262 bytesAll this trouble for nothing.. >.> ;)
(Shorter Java answer by @OliverGrégoire.)
Explanation:
Try it here.
sumber
char
instead of anint
in the loop. It allows you to not cast it later on.t
can be initialized and reinitialized to zero and+=
afterwards. It should still be shorter.int
&(char)
&t=...;
vschar
&{t=1;t*=...;}
. Unless I'm missing something.Plain TeX, 306 bytes
Ungolfed with some explanations:
sumber
05AB1E, 120 bytes
Try it online!
There's way too much golfing to do here, will post explanation when I'm below 90 bytes.
sumber
Stax,
536864 bytesRun and debug it
Unpacked and ungolfed it looks like this.
Note that if you use the "Golf" button to remove whitespace and comments from the expanded solution, it incorrectly doubles the
}
. If you remove the extra character, it continues to work correctly.sumber
C (gcc),
217211 bytes-6 bytes thanks to ceilingcat
Try it online!
sumber
///, 264 bytes
Try it online!
Works by defining a bunch of replacements and using them to replace more characters than they are.
sumber
Mathematica, 274 bytes
sumber
Charcoal,
154 149 143 130103 bytesTry it online! (Link to verbose version.)
sumber
\\r
: Try it online!. Note that I've inserted dummy operations because I'm not getting any separators.\r
trick, I didn't know that.Bubblegum, 150 bytes
Try it online!
sumber
Perl6,
225219sumber
Lua, 380 bytes
Uses
gsub
to create the row dividers and the seeding rows.l
generates the leeching rows. Renaminggsub
andrep
saves more bytes.sumber
Jstx, 126 bytes
Try it online!
Explanation
I'm sure this can get significantly shorter.
sumber
///, 226 bytes
Try it online!
A bit more sophisticated approach to defining replacements. Try it interactively here!
sumber
Pascal (FPC),
294286266263 bytesTry it online!
So... I ended up with both leading and trailing newline :D
sumber
PowerShell,
224210181174169160 bytesTry it online!
Now 64 bytes less terrible
Some Neat tricks: Combining a lot of "$(stuff)" to save on parens. We want only odd numbers which makes $_%2 = 1 so we don't need an -eq for it. Now uses list indexing instead of an if-else to save 5 bytes. Also gets rid of an `n for another byte. I couldn't get "$c`0%" to separate the var and zero so the current route was 1 byte shorter than gluing two strings together. Now with -f formatting.
sumber