/**
 * Given a grid represented by a list of lists, this function finds the location of the treasure.
 *
 * The grid consists of 'X' representing obstacles, 'T' representing treasure, and '.' representing empty spaces.
 * The archaeologist can only move in four directions: up, down, left, and right.
 * The function should return the coordinates of the treasure as a Pair<Int, Int>, or null if the treasure is not found.
 *
 * Hint: To find the treasure, the archaeologist needs to collect all four parts of a broken artifact by stepping on them.
 * Each part will be represented as the letter 'A' on the grid.
 * The archaeologist can use the AND operator and the break statement to optimize the search.
 */
fun findTreasure(grid: List<List<Char>>): Pair<Int, Int>? {

    for (row in grid.indices) {
        for (col in grid[row].indices) {
            if (grid[row][col] == 'A') {
                if (row > 0 && grid[row - 1][col] == 'T' && col > 0 && grid[row][col - 1] == 'A') {
                    return Pair(col, row)
                } else if (row < grid.size - 1 && grid[row + 1][col] == 'T' && col < grid[row].size - 1 && grid[row][col + 1] == 'A') {
                    return Pair(col, row)
                }
            }
        }
    }
    return null
}
/**
 * Given a grid represented by a list of lists, this function finds the location of the treasure.
 *
 * The grid consists of 'X' representing obstacles, 'T' representing treasure, and '.' representing empty spaces.
 * The archaeologist can only move in four directions: up, down, left, and right.
 * The function should return the coordinates of the treasure as a Pair<Int, Int>, or null if the treasure is not found.
 *
 * Hint: To find the treasure, the archaeologist needs to collect all four parts of a broken artifact by stepping on them.
 * Each part will be represented as the letter 'A' on the grid.
 * The archaeologist can use the AND operator and the break statement to optimize the search.
 */
fun findTreasure(grid: List<List<Char>>): Pair<Int, Int>? {
/**
 * Given a grid represented by a list of lists, this function finds the location of the treasure.
 *
 * The grid consists of 'X' representing obstacles, 'T' representing treasure, and '.' representing empty spaces.
 * The archaeologist can only move in four directions: up, down, left, and right.
 * The function should return the coordinates of the treasure as a Pair<Int, Int>, or null if the treasure is not found.
 *
 * Hint: To find the treasure, the archaeologist needs to collect all four parts of a broken artifact by stepping on them.
 * Each part will be represented as the letter 'A' on the grid.
 * The archaeologist can use the AND operator and the break statement to optimize the search.
 */
fun findTreasure(grid: List<List<Char>>): Pair<Int, Int>? {

    for (row in grid.indices) {
        for (col in grid[row].indices) {
            if (grid[row][col] == 'A') {
                if (row > 0 && grid[row - 1][col] == 'T' && col > 0 && grid[row][col - 1] == 'A') {
                    return Pair(col, row)
                } else if (row < grid.size - 1 && grid[row + 1][col] == 'T' && col < grid[row].size - 1 && grid[row][col + 1] == 'A') {
                    return Pair(col, row)
                }
            }
        }
    }
    return null
}