/**
 * This function takes a square matrix as input and returns the sums of the two diagonals of the matrix.
 *
 * @param matrix A 2D list representing the square matrix.
 * @return A Pair containing the sum of the main diagonal and the sum of the secondary diagonal.
 *
 * Example:
 * If the input matrix is [[1, 2, 3], [4, 5, 6], [7, 8, 9]], the output would be Pair(15, 15).
 */
fun getDiagonalSums(matrix: List<List<Int>>): Pair<Int, Int> {

    var n = matrix.size
    var sumMainDiagonal = 0
    var sumSecondaryDiagonal = 0

    for (i in 0 until n) {
        // Iterate through each row in the matrix and update the sums of the diagonals
        for (j in 0 until n) {
            if (i == j) {
                sumMainDiagonal += matrix[i][j]
            }
            if (i + j == n - 1) {
                sumSecondaryDiagonal += matrix[i][j]
            }
        }

        // Remove the current row from the matrix
        matrix.drop(i)
        n--
    }

    return Pair(sumMainDiagonal, sumSecondaryDiagonal)
}
/**
 * This function takes a square matrix as input and returns the sums of the two diagonals of the matrix.
 *
 * @param matrix A 2D list representing the square matrix.
 * @return A Pair containing the sum of the main diagonal and the sum of the secondary diagonal.
 *
 * Example:
 * If the input matrix is [[1, 2, 3], [4, 5, 6], [7, 8, 9]], the output would be Pair(15, 15).
 */
fun getDiagonalSums(matrix: List<List<Int>>): Pair<Int, Int> {
/**
 * This function takes a square matrix as input and returns the sums of the two diagonals of the matrix.
 *
 * @param matrix A 2D list representing the square matrix.
 * @return A Pair containing the sum of the main diagonal and the sum of the secondary diagonal.
 *
 * Example:
 * If the input matrix is [[1, 2, 3], [4, 5, 6], [7, 8, 9]], the output would be Pair(15, 15).
 */
fun getDiagonalSums(matrix: List<List<Int>>): Pair<Int, Int> {

    var n = matrix.size
    var sumMainDiagonal = 0
    var sumSecondaryDiagonal = 0

    for (i in 0 until n) {
        // Iterate through each row in the matrix and update the sums of the diagonals
        for (j in 0 until n) {
            if (i == j) {
                sumMainDiagonal += matrix[i][j]
            }
            if (i + j == n - 1) {
                sumSecondaryDiagonal += matrix[i][j]
            }
        }

        // Remove the current row from the matrix
        matrix.drop(i)
        n--
    }

    return Pair(sumMainDiagonal, sumSecondaryDiagonal)
}