/**
 * A carpenter needs to cut pieces of wood with given length and width into smaller equal-sized pieces.
 * Using nested loops and the 'less than' condition, complete the function to determine the maximum size of the pieces
 * that the carpenter can cut without any wastage.
 *
 * @param length an integer representing the length of the wood in inches.
 * @param width an integer representing the width of the wood in inches.
 * @return The maximum size of the equal-sized pieces that can be cut from the wood without any wastage.
 */
fun cutWood(length: Int, width: Int): Int {

    var maxSize = 0

    // Iterate over all possible sizes of wood pieces
    for (size in 1..minOf(length, width)) {
        for (i in 0 until length step size) {
            for (j in 0 until width step size) {
                // Check if the current piece fits completely within the wood
                if (i + size <= length && j + size <= width) {
                    // Update the maxSize if the current size is larger
                    maxSize = maxOf(maxSize, size)
                }
            }
        }
    }

    return maxSize
}
/**
 * A carpenter needs to cut pieces of wood with given length and width into smaller equal-sized pieces.
 * Using nested loops and the 'less than' condition, complete the function to determine the maximum size of the pieces
 * that the carpenter can cut without any wastage.
 *
 * @param length an integer representing the length of the wood in inches.
 * @param width an integer representing the width of the wood in inches.
 * @return The maximum size of the equal-sized pieces that can be cut from the wood without any wastage.
 */
fun cutWood(length: Int, width: Int): Int {
/**
 * A carpenter needs to cut pieces of wood with given length and width into smaller equal-sized pieces.
 * Using nested loops and the 'less than' condition, complete the function to determine the maximum size of the pieces
 * that the carpenter can cut without any wastage.
 *
 * @param length an integer representing the length of the wood in inches.
 * @param width an integer representing the width of the wood in inches.
 * @return The maximum size of the equal-sized pieces that can be cut from the wood without any wastage.
 */
fun cutWood(length: Int, width: Int): Int {

    var maxSize = 0

    // Iterate over all possible sizes of wood pieces
    for (size in 1..minOf(length, width)) {
        for (i in 0 until length step size) {
            for (j in 0 until width step size) {
                // Check if the current piece fits completely within the wood
                if (i + size <= length && j + size <= width) {
                    // Update the maxSize if the current size is larger
                    maxSize = maxOf(maxSize, size)
                }
            }
        }
    }

    return maxSize
}