Tiba-tiba saya benar-benar ingin bermain tenis, tetapi sayangnya saya tidak memiliki lapangan!
Mengherankan! Ini adalah di mana Anda datang.
Anda harus mencetak lapangan tenis untuk saya, tetapi Anda harus melakukannya dalam byte sesedikit mungkin karena alasan rahasia.
Lapangan tenis
---------
| |
---------
| | |
xxxxxxxxx
| | |
---------
| |
---------
Jawaban:
Kanvas , 13 byte
Coba di sini!
sumber
Python 2, 65 byte
Flp.Tkc menyimpan satu byte.
sumber
'|'+' '*7
string keduas
untuk menghemat satu byte!05AB1E ,
292726 byteCobalah online!
sumber
9'-×D'|4ð׫©ûs®¨'|«û5'x×»û
mencoba refactoring sedikit, tidak dapat merusak 26.Python 3 -
7372 bytePython 3.6 - 75 byte
Kredit jatuh ke flp-tkc . Terima kasih :)
Coba di sini!
sumber
/// ,
6456 byteCobalah online!
Solusi 56 byte lainnya:
sumber
V , 25 byte
Cobalah online!
Ini harus 23 byte:
Tetapi saya menemukan beberapa bug saat membuatnya. :(
sumber
Jelly , 25 byte
TryItOnline!
Saya berharap untuk menggunakan pengulangan pengadilan 1,3,1 kuartal, tetapi tidak bisa memerasnya menjadi kurang (versi mentah menjadi 28:)
“ßṂuB’b4s3x“¢¤¢‘ị“- x|”ŒBŒḄY
.Bagaimana?
sumber
J,
70545150 byteMenyimpan satu byte berkat Zgarb!
Beberapa teknik kompresi standar, menggunakan RLE terkompresi.
sumber
9 9$'-| |-| | |x| | |'#~3 9 1 7{~4#.inv 1851926050
Ruby, 60 byte
Tidak disatukan
sumber
bash / alat Unix,
5857 byteHanya empat karakter selain baris baru muncul dalam output yang diinginkan, yang memungkinkan setiap baris dikodekan sebagai nomor basis-4. Angka-angka ini kemudian ditulis dalam heksadesimal dalam skrip, untuk singkatnya.
Kalkulator Unix dc digunakan baik untuk konversi basis-16 ke basis-4 maupun manipulasi tumpukan untuk memudahkan pengulangan garis di tempat yang tepat.
Sunting: Memangkas satu byte dengan menukar dua digit basis-4 yang digunakan untuk mengkode karakter, memungkinkan perintah tr menjadi satu byte lebih pendek dari versi sebelumnya.
sumber
JavaScript, 85 byte
sumber
JavaScript (ES6),
86848381 byteDisimpan 2 byte, terima kasih kepada Neil
Alternate method #1, 93 bytes
Alternate method #2, 86 bytes
Suggested by Neil:
Alternate method #3, 91 bytes
A recursive approach:
sumber
console.log('-9\n| 7|\n-9\n| 3| 3|\nx9\n| 3| 3|\n-9\n| 7|\n-9'.replace(/.\d/g,s=>s[0].repeat(s[1])))
(replace\n
with newline obviously).console.log('-\n |\n-\n |\nx\n |\n-\n |\n-'.replace(/.*/g,s=>s.repeat(9).slice(-9)))
.|
as appropriate instead of the single space that appears in my comment.SOGL 0.5,
242320 bytes (non-competing)Explanation:
So how does the compressed string work?
The string converted from base250 to binary is
1000000100111110010100001110100000001100010001
and approxametally what it does:
non-competing, because language postdates the challenge. And this challenge is only a day old. I knew I should've put something up yesterday. I did this as a test for my language and it ended up too good not to post. Pretty sure this is golfable more too.
sumber
///, 59 bytes
Try it online!
Outgolfed...
sumber
Javascript (ES6), 86 bytes:
Test here:
sumber
b
, as this means that you can remove the newline afterxxxxxxxxx
and the one that you add betweena
andb
. You can save a further 3 bytes by settinga
to---------
first and then concatenating the second row and a to itself.05AB1E, 26 bytes
Uses the CP-1252 encoding. Try it online!
sumber
PHP,
6662 bytesThis is the original answer (66 bytes):
It generates a notice because of the unknown constant
x
. The notice can be suppressed by settingerror_reporting=0
inphp.ini
or in the command line:The last line of the output doesn't end with a newline character.
The updated answer (62 bytes), improving an improvement suggested by @Titus:
Run it without a configuration file (it defaults with
error_reporting=0
this way):Both versions of the code contain literal new lines embedded in the string (1 byte shorter than
\n
) and cannot we unwrapped.sumber
-d error_reporting=0
, just use-n
.<?=$a=($b="---------\n|")."...
.-n
is much shorter than-d error_reporting=0
:-) There are, indeed, only 66 useful chars in the answer. I counted them usingls -l
and forgot myvi
is configured to ensure the file ends with a new line. I improved your improvement and squeezed 3 more bytes. Thank you.PHP, 72 bytes
I almost hate it when it´s shorter like this than with calculating a little.
sumber
Ruby, 52 bytes
Using the double simmetry, the lines are:
0-1-0 / 2-3-2 / 0-1-0
, the loop can be easily unrolled and the nested list is flattened on output.sumber
Pyke,
282625 bytesTry it here!
sumber
05AB1E, 25 bytes
Uses the CP-1252 encoding. Try it online!
Explanation:
sumber
Vim, 32 bytes
This will print the tennis court into a vim buffer.
^M
represents the Enter key (0x0d) and^[
is the Escape key (0x1b). You can run these keystrokes/code by saving them to a file and runningPrinting to stdout
If it has to be printed to stdout instead, you could save the buffer to a file (I used "a") and use whichever shell
vim
is set to use (I usedbash
) as well as thecat
program in order to print the tennis court to stdout (51 bytes):It's the same as the earlier version but with
:w!a|sil !cat %^M:q^M
added onto the endsumber
J, 36 bytes
This works on the REPL, which is the standard way of using J:
With 41 bytes, I can print the result to STDOUT:
Try it online!
Explanation
I construct the tennis court one row at a time.
sumber
PowerShell,
6766 bytesTry it online!
Just some string multiplication, setting variables, and ensuring they're encapsulated in parens to place copies on the pipeline. The default
Write-Output
at program completion gives us newlines between for free.Thanks to @ConnorLSW for saving an obvious byte.
sumber
$(' '*7)
is actually 8 chars, would be shorter to just do| |
as spaces.ToLower()
save on my other answer ;)Python 2, 75 bytes
Uses variables borrowed from @GurupadMamadapur
Alternative also for 75
sumber
Emacs,
4335 keystrokesM-9
x
RET : nine x's, returnC-SPC : set mark
|
M-3 SPC|
M-3 SPC|
RET : pipe, three spaces, pipe, three spaces, pipe, returnM-9
-
RET : nine hyphens, return|
M-7 SPC|
RET : pipe, seven spaces, pipe, returnM-9
-
RET : nine hyphens, returnC-x C-x : exchange point and mark, selecting region
M-w : copy region
C-p : previous line
C-y : yank copied text
M-x
rev-r
RET : executereverse-region
commandsumber
Lua, 82 Bytes.
I tried many methods, and yet this one proved the victor.
sumber
Pushy, 33 bytes
This question had 33 upvotes, and there were 33 answers, so I just had to post a 33 byte solution...
Try it online!
Explanation
The code can be split into several parts, to make it easier to understand. The first part works like so:
The stack is now:
The mirror operator,
w
, then mirrors the whole stack, producing:Then:
The stack is now beginning to look like the tennis court:
To finish it, we use the mirror operator
w
once more, which reflects this string to produce the full tennis court.All that's left now is to print, which is done by the
"
character.sumber
Unix Shell; using dc and tr; 55 Bytes: ( Optimization of Mitchell Spector solution )
Others Solutions : Using sed; 81 Bytes;
Using dc in function : 88 Bytes
or
Using bc in function : 99 Bytes
sumber
Powershell, 56 bytes
Explanation: straightforward half-of-the-court
Alternative, 68 bytes
Explanation: quarter-of-the-court uses the same indexes for both row and column display
sumber