QuestionQuestion

The program will first read the number of rows and the number of columns in the puzzle followed by the puzzle itself (the rectangular array of letters). Next, the program will read the list of words to be searched for in the puzzle into an array of structs.

As output, the program will first echo print all of the data read properly labeled.
Next each of the words and whether the word was found or not will be outputted. For each word found, the following information will be printed:
1) word
2) row found
3) column found
4) word's orientation (horizontal, vertical, diagonalLR, diagonalRL)

If the word was not found, print:
1) word
2) the message NOT FOUND

The program assumes that each word occurs at most once (but note that a letter in the puzzle may be part of more than one word).

The program presently searches for words in the following ways:

1) horizontally (left to right)
2) vertically (top to bottom)
3) diagonally (upper-left to lower-right)
4) diagonally (upper-right to lower-left)

It is quite easy to modify the program to search for additional directions

Consider the following puzzle.txt data file:
6 4
THAY
EHRJ
FZEO
YHUB
IJGH
NHIB
THAT
THE
HIP
JOB

The program SHOULD output:

******************************
*       Find A Word         *
******************************

Number of Rows:    6
Number of Columns: 4

Puzzle
------
THAY
EHRJ
FZEO
YHUB
IJGH
NHIB
Words
-----
THAT                         NOT FOUND
THE                           FOUND (Row: 1 Column: 1 Diagonally UL to LR)
HIP                            NOT FOUND
JOB                            FOUND (Row: 2 Column: 4 Vertically)

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

//******************************************************************************
// GLOBAL CONSTANTS
//******************************************************************************
#define MAX_WORD_LENGTH 32 // includes \0
#define EXTRA_SPACE 2
#define MAX_WORDS 25
#define MAX_ROWS 20
#define MAX_COLS 20
#define PUZZLE_BORDER 1    // 1 element border of '\0' around puzzle
// only 1 is allowed in this implementation

#define MAX_BOARD_COLS PUZZLE_BORDER + MAX_COLS + PUZZLE_BORDER
#define MAX_BOARD_ROWS PUZZLE_BORDER + MAX_ROWS + PUZZLE_BORDER

#define MAX_ORIENTATION_DESCRIPTION 20

//******************************************************************************
// PROGRAMMER-DEFINED DATA TYPES
//******************************************************************************

typedef enum DirectionRow {
    DEC_ROW = -1, SAME_ROW, INC_ROW
} DirectionRow;

typedef enum DirectionCol {
    DEC_COL = -1, SAME_COL, INC_COL
} DirectionCol;

typedef enum SearchDirection {
    HORIZONTAL, VERTICAL, DIAGONAL_UL_LR, DIAGONAL_UR_LL
} SearchDirection;

typedef struct OrientationData {
    DirectionRow eRowDirection;
    DirectionCol eColumnDirection;
    SearchDirection eSearchDirection;
    char szDirectionDesription[MAX_ORIENTATION_DESCRIPTION];
} OrientationData;...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$60.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats