Question: Problem C: Square Letter Puzzles Joe Coder is preparing a mobile app with a letter puzzle game. Each puzzle piece in his game consists of

Problem C: Square Letter Puzzles Joe Coder is preparing a mobile app with a letter puzzle game. Each puzzle piece in his game consists of four letters arranged in a square, such as: AB CD He decided to use only uppercase letters and the underscore (_) character in his puzzles. Additionally, he wants to arrange these puzzle pieces into larger square patterns. For example, if you we are given the following four pieces presented in a linear order: AB AA XY OP CD __ YX QZ he will need to rearrange them into the pattern: AB AA CD __ XY OP YX QZ Your task is to write a program for rearranging the pieces from the linear order into a square pattern. You must follow the same order of pieces, with pieces going row by row in the pattern. Input The input consists of one or more test cases. Each test case starts with an integer n 2 on a line (n 2 > 0), which is the number of puzzle pieces. This is followed by two lines containing letters of the puzzle pieces. The first line contains top letters and the second line contains bottom letters of the pieces. Letters of one piece are separated from the letters of the next piece with one space character. The input ends with the number 0. Output For each test case, you first must print the line: New puzzle (n x n): with nn being the puzzle dimensions, followed by the puzzle pieces arranged into a square. You should take a look at the sample output for the exact format. Horizontal pieces are separated by a space, and to make code easier, there is a space in front of the first piece as well. Similarly, pieces are separated by an empty line vertically, and there is an empty line after the last row as well. Some Programming Hints An easy way to store pieces is to use a 2-dimensional VLA. When reading letters from the input, you may find it helpful to use a command that looks similar to the following line: scanf(" %c", &x); This command ignores any leading whitespace (if there is any), and then stores any visible (nonwhitespace) character into the variable x.Problem C: Square Letter Puzzles Joe Coder is preparing a mobile app

Sample Input Sample Output, with visualized whitespace Sample Output New puzzle (2 x 2) : | New..puzzle(2.x.2):B 4 AB AA XY OP AB AA CD AB CD EF MN OP QR YZ A B GH IJKL ST UV WX C D_ E XY OP New puzzle (3 x 3): | New..puzzle-(3.x.3): AB CD EFL AB CD EF GH IJ KL MN OP QRL MN OP QR ST UVWX C D E Note: _ is a space, and Dal is a newline character Sample Input Sample Output, with visualized whitespace Sample Output New puzzle (2 x 2) : | New..puzzle(2.x.2):B 4 AB AA XY OP AB AA CD AB CD EF MN OP QR YZ A B GH IJKL ST UV WX C D_ E XY OP New puzzle (3 x 3): | New..puzzle-(3.x.3): AB CD EFL AB CD EF GH IJ KL MN OP QRL MN OP QR ST UVWX C D E Note: _ is a space, and Dal is a newline character

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!