/**
 * A carpenter wants to cut several wooden planks of different lengths. Each plank can be cut at most 'maxCuts' times.
 * The 'lengths' parameter is a list of the lengths of the planks to be cut.
 *
 * Complete the function to calculate the minimum number of planks that cannot be cut completely using 'maxCuts'.
 *
 * Example:
 * lengths = [5, 8, 6, 3, 9]
 * maxCuts = 2
 *
 * Output:
 * 2
 *
 * In this example, the carpenter should be able to cut all the planks except for two of length 3 and 9.
 */
fun calculateNumberOfCuts(lengths: List<Int>, maxCuts: Int): Int {

    var totalPlanks = lengths.size
    var incompletePlanks = 0

    for (plankLength in lengths) {
        var remainingCuts = maxCuts
        var currentLength = plankLength

        while (currentLength > 0 && remainingCuts > 0) {
            currentLength--
            remainingCuts--
        }

        if (currentLength > 0) {
            incompletePlanks++
        }
    }

    return incompletePlanks
}
/**
 * A carpenter wants to cut several wooden planks of different lengths. Each plank can be cut at most 'maxCuts' times.
 * The 'lengths' parameter is a list of the lengths of the planks to be cut.
 *
 * Complete the function to calculate the minimum number of planks that cannot be cut completely using 'maxCuts'.
 *
 * Example:
 * lengths = [5, 8, 6, 3, 9]
 * maxCuts = 2
 *
 * Output:
 * 2
 *
 * In this example, the carpenter should be able to cut all the planks except for two of length 3 and 9.
 */
fun calculateNumberOfCuts(lengths: List<Int>, maxCuts: Int): Int {
/**
 * A carpenter wants to cut several wooden planks of different lengths. Each plank can be cut at most 'maxCuts' times.
 * The 'lengths' parameter is a list of the lengths of the planks to be cut.
 *
 * Complete the function to calculate the minimum number of planks that cannot be cut completely using 'maxCuts'.
 *
 * Example:
 * lengths = [5, 8, 6, 3, 9]
 * maxCuts = 2
 *
 * Output:
 * 2
 *
 * In this example, the carpenter should be able to cut all the planks except for two of length 3 and 9.
 */
fun calculateNumberOfCuts(lengths: List<Int>, maxCuts: Int): Int {

    var totalPlanks = lengths.size
    var incompletePlanks = 0

    for (plankLength in lengths) {
        var remainingCuts = maxCuts
        var currentLength = plankLength

        while (currentLength > 0 && remainingCuts > 0) {
            currentLength--
            remainingCuts--
        }

        if (currentLength > 0) {
            incompletePlanks++
        }
    }

    return incompletePlanks
}