/**
 * This exercise aims to test your understanding of the basic while loop syntax and dictionary methods in Kotlin, specifically for an Electrician.
 *
 * You are given a map 'appliances' containing the power consumption (in watts) of various electrical appliances in a house. Your task is to calculate the total power consumption of all the appliances.
 *
 * Complete the code below to calculate the total power consumption using a while loop and the appropriate map methods.
 *
 * Example:
 * val appliances = mapOf("refrigerator" to 600, "washing_machine" to 1200, "air_conditioner" to 2000)
 * calculateTotalPower(appliances)
 * Output: 3800
 *
 * Note:
 * - Ensure that the loop continues until all appliances have been iterated.
 * - You may assume that the 'appliances' map will always contain valid key-value pairs.
 */
fun calculateTotalPower(appliances: Map<String, Int>): Int {

    var totalPower = 0
    val appliancesRemaining = appliances.keys.toMutableList()

    while (appliancesRemaining.isNotEmpty()) {
        val appliance = appliancesRemaining.removeAt(0)
        val powerConsumption = appliances.getValue(appliance)
        totalPower += powerConsumption
    }

    return totalPower
}
/**
 * This exercise aims to test your understanding of the basic while loop syntax and dictionary methods in Kotlin, specifically for an Electrician.
 *
 * You are given a map 'appliances' containing the power consumption (in watts) of various electrical appliances in a house. Your task is to calculate the total power consumption of all the appliances.
 *
 * Complete the code below to calculate the total power consumption using a while loop and the appropriate map methods.
 *
 * Example:
 * val appliances = mapOf("refrigerator" to 600, "washing_machine" to 1200, "air_conditioner" to 2000)
 * calculateTotalPower(appliances)
 * Output: 3800
 *
 * Note:
 * - Ensure that the loop continues until all appliances have been iterated.
 * - You may assume that the 'appliances' map will always contain valid key-value pairs.
 */
fun calculateTotalPower(appliances: Map<String, Int>): Int {
/**
 * This exercise aims to test your understanding of the basic while loop syntax and dictionary methods in Kotlin, specifically for an Electrician.
 *
 * You are given a map 'appliances' containing the power consumption (in watts) of various electrical appliances in a house. Your task is to calculate the total power consumption of all the appliances.
 *
 * Complete the code below to calculate the total power consumption using a while loop and the appropriate map methods.
 *
 * Example:
 * val appliances = mapOf("refrigerator" to 600, "washing_machine" to 1200, "air_conditioner" to 2000)
 * calculateTotalPower(appliances)
 * Output: 3800
 *
 * Note:
 * - Ensure that the loop continues until all appliances have been iterated.
 * - You may assume that the 'appliances' map will always contain valid key-value pairs.
 */
fun calculateTotalPower(appliances: Map<String, Int>): Int {

    var totalPower = 0
    val appliancesRemaining = appliances.keys.toMutableList()

    while (appliancesRemaining.isNotEmpty()) {
        val appliance = appliancesRemaining.removeAt(0)
        val powerConsumption = appliances.getValue(appliance)
        totalPower += powerConsumption
    }

    return totalPower
}