/**
 * This function takes the number of shapes to be printed and the type of shape as arguments and prints the shapes accordingly.
 */
fun printShapes(numShapes: Int, shapeType: String) {

    var i = 1

    while (i <= numShapes) {
        when (shapeType) {
            "square" -> {
                var j = 1
                while (j <= i) {
                    println("#".repeat(i))
                    j++
                }
            }
            "triangle" -> {
                var j = numShapes - i + 1
                while (j > 0) {
                    println(" ".repeat(numShapes - j) + "#".repeat(2 * j - 1))
                    j--
                }
            }
            "diamond" -> {
                var j = 1
                while (j <= numShapes - i) {
                    println(" ".repeat(numShapes - j) + "#".repeat(2 * j - 1))
                    j++
                }
                j = numShapes - i + 1
                while (j > 0) {
                    println(" ".repeat(numShapes - j) + "#".repeat(2 * j - 1))
                    j--
                }
            }
        }
        i++
    }
}
/**
 * This function takes the number of shapes to be printed and the type of shape as arguments and prints the shapes accordingly.
 */
fun printShapes(numShapes: Int, shapeType: String) {
/**
 * This function takes the number of shapes to be printed and the type of shape as arguments and prints the shapes accordingly.
 */
fun printShapes(numShapes: Int, shapeType: String) {

    var i = 1

    while (i <= numShapes) {
        when (shapeType) {
            "square" -> {
                var j = 1
                while (j <= i) {
                    println("#".repeat(i))
                    j++
                }
            }
            "triangle" -> {
                var j = numShapes - i + 1
                while (j > 0) {
                    println(" ".repeat(numShapes - j) + "#".repeat(2 * j - 1))
                    j--
                }
            }
            "diamond" -> {
                var j = 1
                while (j <= numShapes - i) {
                    println(" ".repeat(numShapes - j) + "#".repeat(2 * j - 1))
                    j++
                }
                j = numShapes - i + 1
                while (j > 0) {
                    println(" ".repeat(numShapes - j) + "#".repeat(2 * j - 1))
                    j--
                }
            }
        }
        i++
    }
}