/**
 * Given two matrices as nested lists, this function multiplies them and returns the resulting matrix.
 * The matrices are represented as list of rows, where each row is a list of numbers.
 *
 * Example:
 * val matrix1 = listOf(listOf(1, 2, 3), listOf(4, 5, 6))
 * val matrix2 = listOf(listOf(7, 8), listOf(9, 10), listOf(11, 12))
 * The product of matrix1 and matrix2 is:
 * [[58, 64], [139, 154]]
 */
fun multiplyMatrices(matrix1: List<List<Int>>, matrix2: List<List<Int>>): List<List<Int>> {

    val result = mutableListOf<List<Int>>()
    for (i in matrix1.indices) {
        val row = mutableListOf<Int>()
        for (j in matrix2[0].indices) {
            var total = 0
            for (k in matrix1[0].indices) {
                total += matrix1[i][k] * matrix2[k][j]
            }
            row.add(total)
        }
        result.add(row)
    }
    return result
}
/**
 * Given two matrices as nested lists, this function multiplies them and returns the resulting matrix.
 * The matrices are represented as list of rows, where each row is a list of numbers.
 *
 * Example:
 * val matrix1 = listOf(listOf(1, 2, 3), listOf(4, 5, 6))
 * val matrix2 = listOf(listOf(7, 8), listOf(9, 10), listOf(11, 12))
 * The product of matrix1 and matrix2 is:
 * [[58, 64], [139, 154]]
 */
fun multiplyMatrices(matrix1: List<List<Int>>, matrix2: List<List<Int>>): List<List<Int>> {
/**
 * Given two matrices as nested lists, this function multiplies them and returns the resulting matrix.
 * The matrices are represented as list of rows, where each row is a list of numbers.
 *
 * Example:
 * val matrix1 = listOf(listOf(1, 2, 3), listOf(4, 5, 6))
 * val matrix2 = listOf(listOf(7, 8), listOf(9, 10), listOf(11, 12))
 * The product of matrix1 and matrix2 is:
 * [[58, 64], [139, 154]]
 */
fun multiplyMatrices(matrix1: List<List<Int>>, matrix2: List<List<Int>>): List<List<Int>> {

    val result = mutableListOf<List<Int>>()
    for (i in matrix1.indices) {
        val row = mutableListOf<Int>()
        for (j in matrix2[0].indices) {
            var total = 0
            for (k in matrix1[0].indices) {
                total += matrix1[i][k] * matrix2[k][j]
            }
            row.add(total)
        }
        result.add(row)
    }
    return result
}