Question Prompt (1 of 1) You are running a classroom and suspect that some of your students...

90.2K

Verified Solution

Question

Programming

Question Prompt (1 of 1)

You are running a classroom and suspect that some of yourstudents are cheating by sharing answers as single words hidden in2D grids of letters.

A particular grid contains at most one word. The word may startanywhere in the grid, and consecutive letters can be either belowor to the right of the previous letter.

The input will consist of a word and a grid. Print the locationof the word in the grid as a list of “row column” coordinates, eachon its own line. If the word does not appear in the grid, justprint “None”.

Example input:

 catnip c r c a r s a b i t n b t f n n t i x s i i p t

Example output

 0 2 0 3 1 3 2 3 3 3 3 4

Clarifications:

  • The word will always appear in the grid exactly 0 or 1times.

Starter code is provided for the following languages: Java, C,C++, JavaScript,

If you wish to use a different language, please write asolution
that reads from STDIN and writes to STDOUT. To obtain startercode,
change the language to one of the previously mentionedlanguages.

Public test 1

Input:

car

c r c r a c a b i t n b t f n n t i

Expected Output:

None

Public test 2

Input:

car

c r c c a r a b i t n b t f n n t i

Expected Output:

0 3 0 4 0 5

Public test 3

Input:

carsick c r c a r s a b i t n b t f n n t i x s c a t n x s d de a s q w x s p

Expected Output:

None

Public test 4

Input:

catnap c r c a r s a b i t n b t f n n t i x s c a t n x s d d ea s q w x s p

Expected Output:

3 2 3 3 3 4 3 5 4 5 5 5

Public test 5

Input:

catnip c r c a r s a b i t n b t f n n t i x s i i p t

Expected Output:

0 2 0 3 1 3 2 3 3 3 3 4

Answer & Explanation Solved by verified expert
4.1 Ratings (643 Votes)
include using namespace std define R 4 define C 7 For searching in 2 direction int x 01 int y 10 This function searches in all 2direction from point row col in grid bool search2Dchar gridRC int row int    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students