/**
 * This function performs matrix multiplication using nested loops for a dancer routine.
 *
 * @param matrix1 The first matrix to be multiplied
 * @param matrix2 The second matrix to be multiplied
 * @return The resulting matrix after matrix multiplication
 * @throws IllegalArgumentException if the number of columns in matrix1 does not match the number of rows in matrix2
 */
fun dancerMatrixMultiplication(matrix1: List<List<Int>>, matrix2: List<List<Int>>): List<List<Int>> {

    // Check if multiplication is possible
    if (matrix1[0].size != matrix2.size) {
        throw IllegalArgumentException("The number of columns in matrix1 must match the number of rows in matrix2")
    }

    // Initialize the resulting matrix with zeros
    val resultMatrix = MutableList(matrix1.size) { MutableList(matrix2[0].size) { 0 } }

    // Multiply the matrices
    for (i in matrix1.indices) {
        for (j in matrix2[0].indices) {
            for (k in matrix2.indices) {
                resultMatrix[i][j] += matrix1[i][k] * matrix2[k][j]
            }
        }
    }

    // Return the resulting matrix
    return resultMatrix
}
/**
 * This function performs matrix multiplication using nested loops for a dancer routine.
 *
 * @param matrix1 The first matrix to be multiplied
 * @param matrix2 The second matrix to be multiplied
 * @return The resulting matrix after matrix multiplication
 * @throws IllegalArgumentException if the number of columns in matrix1 does not match the number of rows in matrix2
 */
fun dancerMatrixMultiplication(matrix1: List<List<Int>>, matrix2: List<List<Int>>): List<List<Int>> {
/**
 * This function performs matrix multiplication using nested loops for a dancer routine.
 *
 * @param matrix1 The first matrix to be multiplied
 * @param matrix2 The second matrix to be multiplied
 * @return The resulting matrix after matrix multiplication
 * @throws IllegalArgumentException if the number of columns in matrix1 does not match the number of rows in matrix2
 */
fun dancerMatrixMultiplication(matrix1: List<List<Int>>, matrix2: List<List<Int>>): List<List<Int>> {

    // Check if multiplication is possible
    if (matrix1[0].size != matrix2.size) {
        throw IllegalArgumentException("The number of columns in matrix1 must match the number of rows in matrix2")
    }

    // Initialize the resulting matrix with zeros
    val resultMatrix = MutableList(matrix1.size) { MutableList(matrix2[0].size) { 0 } }

    // Multiply the matrices
    for (i in matrix1.indices) {
        for (j in matrix2[0].indices) {
            for (k in matrix2.indices) {
                resultMatrix[i][j] += matrix1[i][k] * matrix2[k][j]
            }
        }
    }

    // Return the resulting matrix
    return resultMatrix
}