Function 1 load_treasure_map(filename): Takes a string as input corresponding to a filename. Opens the treasure map at that filename and loads the treasure map into a list of lists, then returns said list of lists. You can assume that the file will exist. Note that the treasure map could have any number of rows and columns. If there is any issue with the format of the file (e.g., it is not a matrix, or contains any invalid characters), then raise an AssertionError with an appropriate error message. Note that an 'X' in a file is valid. Note: In the example below, we show each row of the resulting list on its own line, but when you use doctest, you must put all the rows of the list into one line of code, as doctest checks for any improper whitespace
Function 1 load_treasure_map(filename): Takes a string as input corresponding to a filename. Opens the treasure map at that filename and loads the treasure map into a list of lists, then returns said list of lists. You can assume that the file will exist. Note that the treasure map could have any number of rows and columns. If there is any issue with the format of the file (e.g., it is not a matrix, or contains any invalid characters), then raise an AssertionError with an appropriate error message. Note that an 'X' in a file is valid. Note: In the example below, we show each row of the resulting list on its own line, but when you use doctest, you must put all the rows of the list into one line of code, as doctest checks for any improper whitespace
Function 1 load_treasure_map(filename): Takes a string as input corresponding to a filename. Opens the treasure map at that filename and loads the treasure map into a list of lists, then returns said list of lists. You can assume that the file will exist. Note that the treasure map could have any number of rows and columns. If there is any issue with the format of the file (e.g., it is not a matrix, or contains any invalid characters), then raise an AssertionError with an appropriate error message. Note that an 'X' in a file is valid. Note: In the example below, we show each row of the resulting list on its own line, but when you use doctest, you must put all the rows of the list into one line of code, as doctest checks for any improper whitespace
load_treasure_map(filename): Takes a string as input corresponding to a filename. Opens the treasure map at that filename and loads the treasure map into a list of lists, then returns said list of lists. You can assume that the file will exist. Note that the treasure map could have any number of rows and columns. If there is any issue with the format of the file (e.g., it is not a matrix, or contains any invalid characters), then raise an AssertionError with an appropriate error message. Note that an 'X' in a file is valid. Note: In the example below, we show each row of the resulting list on its own line, but when you use doctest, you must put all the rows of the list into one line of code, as doctest checks for any improper whitespace
Function 2
write_treasure_map(treasure_map, filename): Takes as inputs a list of lists corresponding to a treasure map and a string corresponding to a filename. Writes the treasure map to a file at the given filename, with a newline after each row of the map. Does not return anything.
Function 3
write_X_to_map(filename, row, col): Takes as inputs a string corresponding to a filename, and two non-negative integers representing a row and column index. Reads in the map at the given filename, inserts an X into the given row and column position, then saves the map to a new file with 'new_' prepended to the given filename. You can assume the filename given to the function as argument refers to a file that exists.
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.