/**
 * You are an accountant who needs to apply different discounts to the invoice amount.
 * Write a function that takes in the invoice amount and a list of discounts and computes the final amount
 * after applying all the discounts. Each discount is represented as a tuple where the first element is the
 * discount percentage and the second element is the number of times the discount should be applied.
 *
 * @param invoice The initial invoice amount.
 * @param discounts A list of tuples representing the discounts.
 * @return The final amount after applying all the discounts.
 *
 * Example:
 * applyDiscounts(1000.0, listOf(Pair(10, 2), Pair(5, 3))) // 855.0
 * applyDiscounts(2000.0, listOf(Pair(20, 1), Pair(10, 3), Pair(5, 2))) // 1003.75
 */
fun applyDiscounts(invoice: Double, discounts: List<Pair<Int, Int>>): Double {

    var finalAmount = invoice

    for ((discountPercentage, discountTimes) in discounts) {
        val discount = finalAmount * discountPercentage / 100
        finalAmount -= discount * discountTimes
    }

    return finalAmount
}
/**
 * You are an accountant who needs to apply different discounts to the invoice amount.
 * Write a function that takes in the invoice amount and a list of discounts and computes the final amount
 * after applying all the discounts. Each discount is represented as a tuple where the first element is the
 * discount percentage and the second element is the number of times the discount should be applied.
 *
 * @param invoice The initial invoice amount.
 * @param discounts A list of tuples representing the discounts.
 * @return The final amount after applying all the discounts.
 *
 * Example:
 * applyDiscounts(1000.0, listOf(Pair(10, 2), Pair(5, 3))) // 855.0
 * applyDiscounts(2000.0, listOf(Pair(20, 1), Pair(10, 3), Pair(5, 2))) // 1003.75
 */
fun applyDiscounts(invoice: Double, discounts: List<Pair<Int, Int>>): Double {
/**
 * You are an accountant who needs to apply different discounts to the invoice amount.
 * Write a function that takes in the invoice amount and a list of discounts and computes the final amount
 * after applying all the discounts. Each discount is represented as a tuple where the first element is the
 * discount percentage and the second element is the number of times the discount should be applied.
 *
 * @param invoice The initial invoice amount.
 * @param discounts A list of tuples representing the discounts.
 * @return The final amount after applying all the discounts.
 *
 * Example:
 * applyDiscounts(1000.0, listOf(Pair(10, 2), Pair(5, 3))) // 855.0
 * applyDiscounts(2000.0, listOf(Pair(20, 1), Pair(10, 3), Pair(5, 2))) // 1003.75
 */
fun applyDiscounts(invoice: Double, discounts: List<Pair<Int, Int>>): Double {

    var finalAmount = invoice

    for ((discountPercentage, discountTimes) in discounts) {
        val discount = finalAmount * discountPercentage / 100
        finalAmount -= discount * discountTimes
    }

    return finalAmount
}