27
5
This is a 3x3 ASCII jigsaw puzzle:
_____ _____ _____
| _| |_ |
| (_ _ _) |
|_ _|_( )_|_ _|
| (_) |_ _| (_) |
| _ _) (_ _ |
|_( )_|_ _|_( )_|
| _| (_) |_ |
| (_ _) |
|_____|_____|_____|
This is also a 3x3 ASCII jigsaw puzzle:
_____ _____ _____
| |_ _| |
| _ _) (_ _ |
|_( )_|_ _|_( )_|
| _| (_) |_ |
| (_ _ _) |
|_ _|_( )_|_ _|
| (_) |_ _| (_) |
| _) (_ |
|_____|_____|_____|
Each line in a ASCII jigsaw puzzle (excluding the edge cases i.e. the pieces literally on the edges) consists of the following pattern:
_ _ _
_( )_ _ _ _( )_ _ _ _( )_
|_ _| (_) |_ _| (_) |_ _|
_) (_ _ _) (_ _ _) (_
|_ _|_( )_|_ _|_( )_|_ _| ...
(_) (_) (_)
Given 2 integers H and W where H is the height (vertical amount) and W is the width (horizontal amount) and H and W are >1 output a possible HxW ASCII jigsaw puzzle.
Examples
Test Case 1
Input: 2, 4
Output:
_____ _____ _____ _____
| |_ _| |_ |
| _ _) (_ _ _) |
|_( )_|_ _|_( )_|_ _|
| _| (_) |_ _| (_) |
| (_ _) (_ |
|_____|_____|_____|_____|
Test Case 2
Input: 4, 4
Output:
_____ _____ _____ _____
| |_ _| |_ |
| _ _) (_ _ _) |
|_( )_|_ _|_( )_|_ _|
| _| (_) |_ _| (_) |
| (_ _ _) (_ _ |
|_ _|_( )_|_ _|_( )_|
| (_) |_ _| (_) |_ |
| _ _) (_ _ _) |
|_( )_|_ _|_( )_|_ _|
| _| (_) |_ _| (_) |
| (_ _) (_ |
|_____|_____|_____|_____|
Test Case 3
Input: 3, 5
Output:
_____ _____ _____ _____ _____
| |_ _| |_ _| |
| _ _) (_ _ _) (_ _ |
|_( )_|_ _|_( )_|_ _|_( )_|
| _| (_) |_ _| (_) |_ |
| (_ _ _) (_ _ _) |
|_ _|_( )_|_ _|_( )_|_ _|
| (_) |_ _| (_) |_ _| (_) |
| _) (_ _) (_ |
|_____|_____|_____|_____|_____|
Test Case 4
Input: 2, 2
Output:
_____ _____
| _| |
| (_ _ |
|_ _|_( )_|
| (_) |_ |
| _) |
|_____|_____|
Clarifications
- The height and width for each puzzle piece should not be scaled up or down.
- With
HandWbeing greater than one, the smallest dimensions possible are2x2(see IO 4). - You can have a full program or a function.
- The input will be 2 lines with
Hon the 1st andWon the 2nd if you're using a function you can have them in the parameters. - Output to stdout (or something similar).
- This is code-golf so shortest answer in bytes wins.
Must the tabs of the pieces be in alternating directions? – Zgarb – 2016-12-29T11:44:10.237
Should I output at random or can I output just one puzzle each time around? If at random, should all puzzles be uniformly available? – user48538 – 2016-12-29T11:47:29.077
@Zgarb yes, i edited in the basic pattern each line in the jigsaw puzzle follows – Bobas_Pett – 2016-12-29T11:58:03.667
@zyabin101 you just need to output a possible "ASCII jigsaw puzzle" so only 1 output for 1 input – Bobas_Pett – 2016-12-29T11:59:25.120
1First attempt is looking like it is going to end up at about a megabyte. Nice question. – ElPedro – 2016-12-29T20:14:28.097
@ElPedro thx :) – Bobas_Pett – 2016-12-29T20:28:25.850
Assuming per your spec that dimensions of 1 are allowed, it might be nice to add a 1xn and/or nx1 test case. – H Walters – 2016-12-29T21:37:46.340
Can you relax the input format? This challenge clearly isn't about parsing a string, so I'd allow any program or function that takes two numbers, in any format. – Rainer P. – 2016-12-29T21:39:12.457
@HWalters your right this isn't clear, i totally forgot to mention this. the dimensions are any integers
>1... give me sec ill edit this in – Bobas_Pett – 2016-12-29T21:46:36.687@RainerP. sorry, ill change the format… – Bobas_Pett – 2016-12-29T21:47:24.437