/**
 * This exercise requires the carpenter to perform different tasks using their tools.
 * Complete the code to assign a tool to each task and break out of the loop when all tools have been used or all tasks have been completed.
 *
 * @param carpentryTools A list of available carpentry tools.
 * @param carpenterTasks A list of tasks to be completed.
 * @return A list of tasks that have been completed.
 *
 * Note:
 * Each task requires a different tool, and a single tool may be used for multiple tasks.
 * The number of tools may be greater or smaller than the number of tasks.
 */
fun carpenterJobs(carpentryTools: List<String>, carpenterTasks: List<String>): List<String> {

    val completedTasks = mutableListOf<String>()

    // Assign a tool to each task until all tools have been used or all tasks are completed
    for (task in carpenterTasks) {
        for (tool in carpentryTools) {
            if (completedTasks.contains(tool)) {
                // Skip the current tool if it has already been used for a task
                continue
            }

            // Assign the tool to the task
            println("Task: $task | Tool: $tool")

            // Complete the task and add it to the completed tasks list
            completedTasks.add(task)
            break
        }
    }

    return completedTasks
}
/**
 * This exercise requires the carpenter to perform different tasks using their tools.
 * Complete the code to assign a tool to each task and break out of the loop when all tools have been used or all tasks have been completed.
 *
 * @param carpentryTools A list of available carpentry tools.
 * @param carpenterTasks A list of tasks to be completed.
 * @return A list of tasks that have been completed.
 *
 * Note:
 * Each task requires a different tool, and a single tool may be used for multiple tasks.
 * The number of tools may be greater or smaller than the number of tasks.
 */
fun carpenterJobs(carpentryTools: List<String>, carpenterTasks: List<String>): List<String> {
/**
 * This exercise requires the carpenter to perform different tasks using their tools.
 * Complete the code to assign a tool to each task and break out of the loop when all tools have been used or all tasks have been completed.
 *
 * @param carpentryTools A list of available carpentry tools.
 * @param carpenterTasks A list of tasks to be completed.
 * @return A list of tasks that have been completed.
 *
 * Note:
 * Each task requires a different tool, and a single tool may be used for multiple tasks.
 * The number of tools may be greater or smaller than the number of tasks.
 */
fun carpenterJobs(carpentryTools: List<String>, carpenterTasks: List<String>): List<String> {

    val completedTasks = mutableListOf<String>()

    // Assign a tool to each task until all tools have been used or all tasks are completed
    for (task in carpenterTasks) {
        for (tool in carpentryTools) {
            if (completedTasks.contains(tool)) {
                // Skip the current tool if it has already been used for a task
                continue
            }

            // Assign the tool to the task
            println("Task: $task | Tool: $tool")

            // Complete the task and add it to the completed tasks list
            completedTasks.add(task)
            break
        }
    }

    return completedTasks
}