Problema
Recrie a interface do usuário de um programa torrent
Não havendo entrada, produza o seguinte:
+----------+----------+----------+
|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 |
+----------+----------+----------+
O progresso dos programas é:
b=10% d=20% f=30% h=40% j=50% l=60% n=70% p=80% r=90%
quantidade de #
programas para sanguessugas éprogress/10
o resto é tudo seeding
com barras de progresso completas.
Regras
- Novas linhas iniciais e finais são permitidas.
- Os espaços à esquerda e à direita são permitidos, desde que não alterem a forma da saída.
- stdout e funções para saída permitida.
- O menor código em bytes ganha
code-golf
string
ascii-art
kolmogorov-complexity
LiefdeWen
fonte
fonte
.exe
de torrents não é a coisa mais brilhante a se fazer, não é?f.exe
não consigo encontrar uma cópia dele em nenhum outro lugar.f.exe
vem com of_readme.txt
que diz, "executar como administrador". Parece legítimo.Respostas:
Carvão,
988583 bytesEu pensei que copiar um modelo me pouparia muito código, mas tudo parece acrescentar de alguma forma, embora eu tenha conseguido salvar 13 bytes usando um único loop para corrigir as 9 linhas sanguessugas. Explicação:
(Nota: pareço ter descoberto um bug no Charcoal;
|
é um caractere ASCII, mas também é contado como uma flecha para os fins deMultiprint
, então você não podeMultiprint
.)fonte
Perl 5 , 130 bytes
Experimente online!
Espero que haja alguns bytes que possam ser jogados no golfe, mas fiquei sem inspiração.
Explicações breves:
$e
contém a linha de separação (+----------+----------+----------+
); sua construção é direta (("+"."-"x10)x3 ."+\n"
).Em seguida, alterno os caracteres de
a
paraz
:Toda vez, imprima
"|$_.exe%4s |%-10s|%-9s |\n$e
; esse é um padrãoprintf
com espaços reservados para cadeias de caracteres (%s
) e cadeias de preenchimento à esquerda (%-9s
).if
$|--&&$@++<9
for true ($|
é uma variável especial que contém 0 ou 1, e diminui-la alterna seu valor), a porcentagem não é 100% e os três valores na impressão são"$@0%","#"x$@,leeching
($@0%
na verdade, é apenas$@ . "0" . "%"
lembre-se de que$@
foi incrementado anteriormente) caso contrário, os três valores são"","#"x10,seeding
).fonte
Python 2 ,
182177 bytesAgradecemos a @officialaimm por reduzir 5 bytes, alterando o formato da condição.
Experimente online!
fonte
SOGL V0.12 ,
908988 bytesExperimente aqui!
Explicação:
fonte
Javascript,
232230228226 bytesDemo
Show code snippet
fonte
s
andp
to default function parameters, removing the need for()
s around the function body: Fiddle${x?'leeching ':'seeding '}|
to the following:${x?'leeching':'seeding '} |
?PHP, 179 bytes
without input
Try it online!
PHP, 176 bytes
with input
Try it online!
fonte
++
from++$x&1
(-2), use$y=++$x%4|$z>9?"":++$z."0%"
as secondprintf
parameter (-9) and insert$z
before:10
(+2)Python 3, 255 bytes
I'm sure this can be golfed, updating soon:
Try it online!
fonte
leeching |
andseeding |
, can't you change it intoleeching
andseeding
+" |"
?//2*10
is just*5
and10-(z-96)//2
is just58-z//2
.Ruby, 141 bytes
Try it online!
fonte
Java (OpenJDK 8),
244229228227226224222218217 bytesTry it online!
-2 bytes thanks to @KevinCruijssen!
fonte
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!
fonte
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
fonte
V, 107 bytes
Try it online!
Hexdump:
fonte
Japt, 121 bytes
Try it online!
fonte
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!fonte
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.
fonte
Java 8,
271263262 bytesAll this trouble for nothing.. >.> ;)
(Shorter Java answer by @OliverGrégoire.)
Explanation:
Try it here.
fonte
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:
fonte
05AB1E, 120 bytes
Try it online!
There's way too much golfing to do here, will post explanation when I'm below 90 bytes.
fonte
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.fonte
C (gcc),
217211 bytes-6 bytes thanks to ceilingcat
Try it online!
fonte
///, 264 bytes
Try it online!
Works by defining a bunch of replacements and using them to replace more characters than they are.
fonte
Mathematica, 274 bytes
fonte
Charcoal,
154 149 143 130103 bytesTry it online! (Link to verbose version.)
fonte
\\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!
fonte
Perl6,
225219fonte
Lua, 380 bytes
Uses
gsub
to create the row dividers and the seeding rows.l
generates the leeching rows. Renaminggsub
andrep
saves more bytes.fonte
Jstx, 126 bytes
Try it online!
Explanation
I'm sure this can get significantly shorter.
fonte
///, 226 bytes
Try it online!
A bit more sophisticated approach to defining replacements. Try it interactively here!
fonte
Pascal (FPC),
294286266263 bytesTry it online!
So... I ended up with both leading and trailing newline :D
fonte
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.
fonte