/**
 * The function takes two arguments:
 * - patronList: a list of dictionaries representing the patrons in the library
 * - overdueBooks: a list of dictionaries representing the overdue books with their details
 *
 * This function calculates the total fine amount for each patron based on their overdue books.
 */
fun calculateFine(patronList: List<MutableMap<String, Any>>, overdueBooks: List<MutableMap<String, Any>>): List<MutableMap<String, Any>> {

    for (patron in patronList) {
        patron["fine"] = 0
        for (book in patron["books"] as List<MutableMap<String, Any>>) {
            if (overdueBooks.any { it["id"] == book["id"] }) {
                // Calculate fine as $2 per day for each overdue book
                val fine = 2 * (book["days_overdue"] as Int)
                patron["fine"] = (patron["fine"] as Int) + fine
            }
        }
    }
    return patronList
}
/**
 * The function takes two arguments:
 * - patronList: a list of dictionaries representing the patrons in the library
 * - overdueBooks: a list of dictionaries representing the overdue books with their details
 *
 * This function calculates the total fine amount for each patron based on their overdue books.
 */
fun calculateFine(patronList: List<MutableMap<String, Any>>, overdueBooks: List<MutableMap<String, Any>>): List<MutableMap<String, Any>> {
/**
 * The function takes two arguments:
 * - patronList: a list of dictionaries representing the patrons in the library
 * - overdueBooks: a list of dictionaries representing the overdue books with their details
 *
 * This function calculates the total fine amount for each patron based on their overdue books.
 */
fun calculateFine(patronList: List<MutableMap<String, Any>>, overdueBooks: List<MutableMap<String, Any>>): List<MutableMap<String, Any>> {

    for (patron in patronList) {
        patron["fine"] = 0
        for (book in patron["books"] as List<MutableMap<String, Any>>) {
            if (overdueBooks.any { it["id"] == book["id"] }) {
                // Calculate fine as $2 per day for each overdue book
                val fine = 2 * (book["days_overdue"] as Int)
                patron["fine"] = (patron["fine"] as Int) + fine
            }
        }
    }
    return patronList
}