/**
 * The archaeologist needs to find the treasure in a given map grid.
 * The grid is represented as a list of lists, where each element represents a cell on the grid.
 * The archaeologist must navigate through the grid by following specific rules:
 * - If the current cell contains the target, return its position.
 * - If the adjacent cell to the right contains the target, return its position.
 * - If the adjacent cell to the bottom contains the target, return its position.
 * - If neither of the adjacent cells contains the target, continue searching in the bottom-right quadrant of the grid.
 */
fun findTreasure(mapGrid: List<List<Int>>, target: Int): Pair<Int, Int>? {

    // Set the initial starting point of the archaeologist at the top-left corner of the grid
    var currentRow = 0
    var currentCol = 0

    // Iterate through each row in the grid
    while (currentRow < mapGrid.size) {
        // Check if the current cell contains the target
        if (mapGrid[currentRow][currentCol] == target) {
            return Pair(currentRow, currentCol)
        }

        // Check if the adjacent cell to the right contains the target
        if (currentCol + 1 < mapGrid[0].size && mapGrid[currentRow][currentCol + 1] == target) {
            return Pair(currentRow, currentCol + 1)
        }

        // Check if the adjacent cell to the bottom contains the target
        if (currentRow + 1 < mapGrid.size && mapGrid[currentRow + 1][currentCol] == target) {
            return Pair(currentRow + 1, currentCol)
        }

        // Continue searching in the bottom-right quadrant of the grid
        currentRow++
        currentCol++
    }

    return null
}
/**
 * The archaeologist needs to find the treasure in a given map grid.
 * The grid is represented as a list of lists, where each element represents a cell on the grid.
 * The archaeologist must navigate through the grid by following specific rules:
 * - If the current cell contains the target, return its position.
 * - If the adjacent cell to the right contains the target, return its position.
 * - If the adjacent cell to the bottom contains the target, return its position.
 * - If neither of the adjacent cells contains the target, continue searching in the bottom-right quadrant of the grid.
 */
fun findTreasure(mapGrid: List<List<Int>>, target: Int): Pair<Int, Int>? {
/**
 * The archaeologist needs to find the treasure in a given map grid.
 * The grid is represented as a list of lists, where each element represents a cell on the grid.
 * The archaeologist must navigate through the grid by following specific rules:
 * - If the current cell contains the target, return its position.
 * - If the adjacent cell to the right contains the target, return its position.
 * - If the adjacent cell to the bottom contains the target, return its position.
 * - If neither of the adjacent cells contains the target, continue searching in the bottom-right quadrant of the grid.
 */
fun findTreasure(mapGrid: List<List<Int>>, target: Int): Pair<Int, Int>? {

    // Set the initial starting point of the archaeologist at the top-left corner of the grid
    var currentRow = 0
    var currentCol = 0

    // Iterate through each row in the grid
    while (currentRow < mapGrid.size) {
        // Check if the current cell contains the target
        if (mapGrid[currentRow][currentCol] == target) {
            return Pair(currentRow, currentCol)
        }

        // Check if the adjacent cell to the right contains the target
        if (currentCol + 1 < mapGrid[0].size && mapGrid[currentRow][currentCol + 1] == target) {
            return Pair(currentRow, currentCol + 1)
        }

        // Check if the adjacent cell to the bottom contains the target
        if (currentRow + 1 < mapGrid.size && mapGrid[currentRow + 1][currentCol] == target) {
            return Pair(currentRow + 1, currentCol)
        }

        // Continue searching in the bottom-right quadrant of the grid
        currentRow++
        currentCol++
    }

    return null
}