Please help me write the following function (see the photos for context of the problem): follow_trail(filename, treasure_map, start_row, start_col): Takes as inputs a string corresponding to a filename, a list of lists corresponding to a treasure map, and two non-negative integers representing a row and column index. Follows the trail in the given treasure map, starting at the given row and column index. Following the trail means to look at each character of the trail and perform the appropriate operation for that character: '>', '<', 'v', ' ∧': Continues following the trail by moving to the character to the right, left, below or above the current trail character, respectively. '.': Creates a new map file, with 'new_' prepended to the current map filename, and stores the same treasure map but with an X at the current position. Then, returns a tuple of three elements: the first being -1, and the latter two being the current row and column index. '*': Returns a tuple of three elements: the first being the current map number plus one, and the latter two being the current row and column index. '|': Returns a tuple of three elements: the first being the current map number minus one, and the latter two being the current row and column index. A digit between 0 and 9 (inclusive): Returns a tuple of three elements: the first being said digit between 0 and 9, and the latter two being 0. You can assume that the treasure map given as input will be a valid matrix and contain only the characters above. However, it’s possible that there could be other issues with the treasure map. For example, a trail you follow might lead off the grid. In such case, raise an Asse
Please help me write the following function (see the photos for context of the problem): follow_trail(filename, treasure_map, start_row, start_col): Takes as inputs a string corresponding to a filename, a list of lists corresponding to a treasure map, and two non-negative integers representing a row and column index. Follows the trail in the given treasure map, starting at the given row and column index. Following the trail means to look at each character of the trail and perform the appropriate operation for that character: '>', '<', 'v', ' ∧': Continues following the trail by moving to the character to the right, left, below or above the current trail character, respectively. '.': Creates a new map file, with 'new_' prepended to the current map filename, and stores the same treasure map but with an X at the current position. Then, returns a tuple of three elements: the first being -1, and the latter two being the current row and column index. '*': Returns a tuple of three elements: the first being the current map number plus one, and the latter two being the current row and column index. '|': Returns a tuple of three elements: the first being the current map number minus one, and the latter two being the current row and column index. A digit between 0 and 9 (inclusive): Returns a tuple of three elements: the first being said digit between 0 and 9, and the latter two being 0. You can assume that the treasure map given as input will be a valid matrix and contain only the characters above. However, it’s possible that there could be other issues with the treasure map. For example, a trail you follow might lead off the grid. In such case, raise an Asse
Please help me write the following function (see the photos for context of the problem): follow_trail(filename, treasure_map, start_row, start_col): Takes as inputs a string corresponding to a filename, a list of lists corresponding to a treasure map, and two non-negative integers representing a row and column index. Follows the trail in the given treasure map, starting at the given row and column index. Following the trail means to look at each character of the trail and perform the appropriate operation for that character: '>', '<', 'v', ' ∧': Continues following the trail by moving to the character to the right, left, below or above the current trail character, respectively. '.': Creates a new map file, with 'new_' prepended to the current map filename, and stores the same treasure map but with an X at the current position. Then, returns a tuple of three elements: the first being -1, and the latter two being the current row and column index. '*': Returns a tuple of three elements: the first being the current map number plus one, and the latter two being the current row and column index. '|': Returns a tuple of three elements: the first being the current map number minus one, and the latter two being the current row and column index. A digit between 0 and 9 (inclusive): Returns a tuple of three elements: the first being said digit between 0 and 9, and the latter two being 0. You can assume that the treasure map given as input will be a valid matrix and contain only the characters above. However, it’s possible that there could be other issues with the treasure map. For example, a trail you follow might lead off the grid. In such case, raise an Asse
Takes as inputs a string corresponding to a filename, a list of lists corresponding to a treasure map, and two non-negative integers representing a row and column index. Follows the trail in the given treasure map, starting at the given row and column index. Following the trail means to look at each character of the trail and perform the appropriate operation for that character:
'>', '<', 'v', ' ∧': Continues following the trail by moving to the character to the right, left, below or above the current trail character, respectively.
'.': Creates a new map file, with 'new_' prepended to the current map filename, and stores the same treasure map but with an X at the current position. Then, returns a tuple of three elements: the first being -1, and the latter two being the current row and column index.
'*': Returns a tuple of three elements: the first being the current map number plus one, and the latter two being the current row and column index.
'|': Returns a tuple of three elements: the first being the current map number minus one, and the latter two being the current row and column index.
A digit between 0 and 9 (inclusive): Returns a tuple of three elements: the first being said digit between 0 and 9, and the latter two being 0.
You can assume that the treasure map given as input will be a valid matrix and contain only the characters above. However, it’s possible that there could be other issues with the treasure map. For example, a trail you follow might lead off the grid. In such case, raise an AssertionError with an appropriate error message. There are other cases of invalid treasure maps that you should also consider and raise an AssertionError for. We will leave these other cases up to you to discover. In other words, your function should never raise any exception other than AssertionError no matter what input is given for the treasure map argument (as long as it is a valid matrix and contains only the characters above). Show an example in your docstring for each different AssertionError that could be raised. These examples are in addition to the three examples that your function must normally have.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.