/**
 * Given an initial account balance and a list of transactions, calculate the closing balance.
 *
 * @param accountBalance The initial account balance.
 * @param transactions A list of pairs representing each transaction, with the format (amount, type).
 * @return The closing balance after applying all the transactions.
 */
fun calculateClosingBalance(accountBalance: Double, transactions: List<Pair<Double, String>>): Double {

    var closingBalance = accountBalance

    for (transaction in transactions) {
        val (amount, transactionType) = transaction

        if ((amount > 0 && transactionType == "credit") || (amount < 0 && transactionType == "debit")) {
            closingBalance += amount
        }
    }

    return closingBalance
}
/**
 * Given an initial account balance and a list of transactions, calculate the closing balance.
 *
 * @param accountBalance The initial account balance.
 * @param transactions A list of pairs representing each transaction, with the format (amount, type).
 * @return The closing balance after applying all the transactions.
 */
fun calculateClosingBalance(accountBalance: Double, transactions: List<Pair<Double, String>>): Double {
/**
 * Given an initial account balance and a list of transactions, calculate the closing balance.
 *
 * @param accountBalance The initial account balance.
 * @param transactions A list of pairs representing each transaction, with the format (amount, type).
 * @return The closing balance after applying all the transactions.
 */
fun calculateClosingBalance(accountBalance: Double, transactions: List<Pair<Double, String>>): Double {

    var closingBalance = accountBalance

    for (transaction in transactions) {
        val (amount, transactionType) = transaction

        if ((amount > 0 && transactionType == "credit") || (amount < 0 && transactionType == "debit")) {
            closingBalance += amount
        }
    }

    return closingBalance
}