Quantcast
Channel: Active questions tagged tiling - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 35

ASCII Jigsaw Puzzle

$
0
0

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 H and W being greater than one, the smallest dimensions possible are 2x2 (see IO 4).
  • You can have a full program or a function.
  • The input will be 2 lines with H on the 1st and W on 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.

Viewing all articles
Browse latest Browse all 35

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>