# Function to read the grid from the file # This will read the website as a file as store the grid def read_grid(): url = "http://54.243.252.9/engr-1330-webroot/8-Labs/Lab07/treasure1.txt" grid = [] with open(url, "r") as file: for line in file: new = line.split() grid.append(list(new)) print(grid) return grid grid = [ [34, 21, 32, 41, 25], [14, 42, 43, 14, 31], [54, 45, 52, 42, 23], [33, 15, 51, 31, 35], [21, 52, 33, 13, 23] ] # Set intial values for tresure hunt row, col = 0, 0 while True: # Print position of current cell current = grid[row][col] print("Visiting: ", row+1, col+1) # If value of cell equals its coorintates, we found treasure if current == ((row + 1) * 10) + (col + 1): print("Treasure found at cell (", row+1, ", ", col+1, ")!!!!!!!") break # End the loop # Otherwise, print that we didnt find it print("Cell does not contain the treasure.") # Get the next position next_row = current // 10 - 1 # Values 10's digit next_col = current % 10 - 1 # Values 1's digit # Define the next cell row, col = next_row, next_col # Main function to run the treasure hunt