Introduction:
I saw there was only one other badminton related challenge right now. Since I play badminton myself (for the past 13 years now), I figured I'd add some badminton-related challenges. Here the second (first one can be found here):
Challenge:
Some rules about badminton serves:
- A serve will always be done diagonally over the net.
- You must always serve after the line that's parallel and nearest to the net.
- The area in which you are allowed to serve differs depending on whether it's a single (1 vs 1) or double/mix (2 vs 2).
- For singles (1 vs 1), the blue area in the picture below is where you are allowed to serve. So this is including the part at the back, but excluding the parts at the side.
- For doubles/mix (2 vs 2), the green area in the picture below is where you are allowed to server. So this is excluding the part at the back, but including the parts at the side.
- You may not stand on the lines when serving. But the shuttle will still be inside if they land on top of a line.
Here the layout of a badminton field:
Challenge rules:
Input:
You will be given two inputs:
- Something to indicate whether we're playing a single or double/mix (i.e. a boolean)
- Something to indicate which block you're serving from (i.e.
[1,2,3,4]
or['A','B','C','D']
as used in the picture above).
Output:
Only the relevant lines for the current serve (including the net), including an F
to indicate where you serve from, and multiple T
to indicate where you will potentially serve to.
Although in reality you're allowed to serve from and to anywhere in the designated areas, we assume a person that will serve will always stands in the corner of the serve area closes to the middle of the net, which is where you'll place the F
. And they will serve to any of the four corners of the area where they have to serve to, which is where you'll place the T
s.
As ASCII-art, the entire badminton field would be the following (the numbers are added so you don't have to count them yourself):
2 15 15 2
+--+---------------+---------------+--+
| | | | | 1
+--+---------------+---------------+--+
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | 9
| | | | |
| | | | |
| | | | |
| | | | |
+--+---------------+---------------+--+
| | | | | 2
| | | | |
O=====================================O 37 times '='
| | | | |
| | | | | 2
+--+---------------+---------------+--+
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | 9
| | | | |
| | | | |
| | | | |
| | | | |
+--+---------------+---------------+--+
| | | | | 1
+--+---------------+---------------+--+
Examples:
Here two examples for outputting only the relevant parts of the serve:
Input: Single and serve block A
Output:
T---------------T
| |
+---------------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
T---------------T
| |
| |
O=====================================O
| |
| |
+---------------+
| F|
| |
| |
| |
| |
| |
| |
| |
| |
+---------------+
| |
+---------------+
As you can see, the F
is added in the corner within the block, but the T
are replacing the +
in the ASCI-art output.
Input: Double and serve block C
Output:
+--+---------------+
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | F|
+--+---------------+
| | |
| | |
O=====================================O
| | |
| | |
T---------------+--T
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
T---------------+--T
Challenge rules:
- Leading and trailing newlines are optional (including the leading and trailing two empty lines when the input is single). Trailing spaces are optional as well. Leading spaces are mandatory however.
- Any four reasonable distinct inputs to indicate which block we're serving from are allowed (for integers, stay within the [-999,999] range); as well as any two reasonable distinct inputs to indicate whether its a single or double/mix (please note this relevant forbidden loophole, though). Please state the I/O you've used in your answer!
- You are allowed to use a lowercase
f
andt
(or mixed case) instead ofF
andT
. - You are allowed to return a list of lines or matrix of characters instead of returning or printing a single output-string.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code (i.e. TIO).
- Also, adding an explanation for your answer is highly recommended.