/**
 * A carpenter needs to find the number of boards of a certain length needed to cover a specific length.
 *
 * @param boardLengths a list of integers representing the lengths of available boards
 * @param requiredLength an integer representing the length that needs to be covered
 * @return A list of integers indicating the number of boards needed (in the same order as given by boardLengths)
 *
 * Example:
 * - boardLengths: [5, 3, 8, 4, 6]
 * - requiredLength: 27
 * - Output: [5, 9, 3, 7, 4]
 */
fun calculateBoardLength(boardLengths: List<Int>, requiredLength: Int): List<Int> {

    val result = mutableListOf<Int>()

    var remainingLength = requiredLength

    for (length in boardLengths) {
        val boardsNeeded = remainingLength / length
        result.add(boardsNeeded)
        remainingLength -= boardsNeeded * length
    }

    return result
}
/**
 * A carpenter needs to find the number of boards of a certain length needed to cover a specific length.
 *
 * @param boardLengths a list of integers representing the lengths of available boards
 * @param requiredLength an integer representing the length that needs to be covered
 * @return A list of integers indicating the number of boards needed (in the same order as given by boardLengths)
 *
 * Example:
 * - boardLengths: [5, 3, 8, 4, 6]
 * - requiredLength: 27
 * - Output: [5, 9, 3, 7, 4]
 */
fun calculateBoardLength(boardLengths: List<Int>, requiredLength: Int): List<Int> {
/**
 * A carpenter needs to find the number of boards of a certain length needed to cover a specific length.
 *
 * @param boardLengths a list of integers representing the lengths of available boards
 * @param requiredLength an integer representing the length that needs to be covered
 * @return A list of integers indicating the number of boards needed (in the same order as given by boardLengths)
 *
 * Example:
 * - boardLengths: [5, 3, 8, 4, 6]
 * - requiredLength: 27
 * - Output: [5, 9, 3, 7, 4]
 */
fun calculateBoardLength(boardLengths: List<Int>, requiredLength: Int): List<Int> {

    val result = mutableListOf<Int>()

    var remainingLength = requiredLength

    for (length in boardLengths) {
        val boardsNeeded = remainingLength / length
        result.add(boardsNeeded)
        remainingLength -= boardsNeeded * length
    }

    return result
}