Latest update

# Let's play tennis 2: east-west game

2018-10-21 22:54:56

There is a topic Let's play tennis by Daniel. He proposes to place a court in the North-South direction. My proposal is to create a court to play tennis in the East-West direction too.

You have to print a tennis court, but you have to do it in the fewest bytes possible because of confidential reasons.

Tennis court

------x------

| | x | |

| |--x--| |

| | x | |

------x------

Original rules are:

no extra spaces;

tabs would be unfair;

only one optional trailing newline is allowed.

This is code-golf, so shortest code in bytes wins!

Charcoal, 15 bytes

↑²←⁶↓xx→x²↑²‖Ｏ¬

Try it online! Link is to verbose version of code. By way of explanation I will show the result after each of the drawing commands up to the final reflection:

↑² |

|

------

←⁶ |

|

x------

↓xx x |

|

x------

→x² x |

x-- |

x------

↑² x | |

x--| |

Canvas, 13 12 bytes

«ω↕9:gＷ：ｔＣ‟┼

• Charcoal, 15 bytes

↑²←⁶↓xx→x²↑²‖Ｏ¬

Try it online! Link is to verbose version of code. By way of explanation I will show the result after each of the drawing commands up to the final reflection:

↑² |

|

------

←⁶ |

|

x------

↓xx x |

|

x------

→x² x |

x-- |

x------

↑² x | |

x--| |

2018-10-21 23:02:48
• Canvas, 13 12 bytes

«ω↕9:gＷ：ｔＣ‟┼

quad-palindromizes a compressed corner of the field.

Try it here!

11 bytes with uppercase Xes, using the fact that / compresses better than x and palindromizing would result in overlapping / and its mirror \, which results in X

2018-10-21 23:06:19
• Dyalog APL, 36 bytes

(⌽,'x',⊢)(⊢⍪'--| |'⍪⊖)'-'⍪1 6⍴' |'

Try it online!

With a little help from Adám

2018-10-21 23:22:26
• Python 3, 75 bytes

s='-'*6;p='| |';w=s+'x'+s;a=p+' x '+p;print(w,a,p+w[4:9]+p,a,w,sep='\n')

Probably golfable - I've never really tried kolmogorov-complexity challenges before.

Try it online!

In Python 2 I could get it to 76 bytes

s='-'*6;p='| |';w=s+'x'+s;a=p+' x '+p

for i in w,a,p+w[4:9]+p,a,w:print i

2018-10-21 23:42:44
• Perl 5, 55 bytes

say\$_,x,~~reverse for('-'x6,'| 'x2,'| |--')[0..2,1,0]

Try it online!

2018-10-21 23:58:27
• Bubblegum, 28 bytes

00000000: d3d5 0581 0a30 a9cb 55a3 a000 4415 60b2 .....0..U...D.`.

00000010: 06cc 03cb c179 0839 5d14 7d00 .....y.9].}.

Try it online!

2018-10-22 00:01:37
• Pip -l, 42 39 34 bytes

RV@

Try it online!

Alternate solution, also 34 bytes:

RV@

Try it online!

2018-10-22 00:07:15
• Python 2, 69 68 bytes

for l in["-","| ","| |--","| ","-"]:l*=6;print l[:6]+"x"+l[5::-1]

Try it online!

We cycle the following three patterns infinitely (6 times is sufficiently infinite for our purposes) and slice off the first 6 characters of each: -, | , and | |--. Then, to get the tennis court, we concatenate an x and the reverse of each line.

2018-10-22 00:27:27