Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function Name: XMarksTheSpot Inputs: 1. (char) An NxM character array representing a map 2. (char) A 1xN character vector representing a series of directions Outputs:

image text in transcribedimage text in transcribed

Function Name: XMarksTheSpot Inputs: 1. (char) An NxM character array representing a map 2. (char) A 1xN character vector representing a series of directions Outputs: 1. (char) A string representing the result and the path you take Background: You and your friends stumble upon an ancient treasure map one day and decide to embark on an adventure. Even though you tell them you'll meet up tomorrow to look for it together, you grow suspicious that they are trying to claim the treasure for themselves! As a CS 1371 student, you decide to use your MATLAB skills to try to find it before your friends do! Function Description: Write a function that navigates through a character array map based on given directions Starting at the top left corner, move according to the following directions Direction Movement 'S Down Right Left W' After each direction, make sure to record your current location (the value of the character in the map). Keep going through the directions until you reach the treasure, represented by an 'X', or reach the end of the directions If you encounter the 'X", your final output should be in the form I found the treasure by following the path along ! If you go through all the given directions and don't find the treasure, output: I went along the path but couldn't find the treasure! Example: map MAUQEHJ OtqlDao aLblIS directions'ESSWSESEEE treasure-XMarksTheSpot(map, directions) treasureI found the treasure by following the path along MAtLaBX! Notes: The instructions will never guide you out of the bounds of the map, and 'N', 'S, 'E', and W are the only directions (no diagonals). If you encounter the travelling further Letters can repeat and the path can intersect with itself. There is no guarantee that there is a treasure in the map There may be multiple treasures, but always stop at the first one. Only capital 'X' counts as a treasure, not 'x' (lowercase) in your path, you should stop there because there's no point in

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

T F Antidepressants are used only to treat depression. (p. 90)

Answered: 1 week ago

Question

=+ 4. Why should policymakers think about incentives?

Answered: 1 week ago

Question

=+ 2. What is the opportunity cost of seeing a movie?

Answered: 1 week ago