/**
 * This function receives a dictionary of order history and returns a tuple containing the number of orders placed,
 * the total revenue, and a dictionary with the number of orders per product category.
 *
 * @param orders A dictionary with the order history, where the keys are the order IDs and the values are
 *               dictionaries with the order details.
 * @return A tuple containing:
 *         - The number of orders placed (Int)
 *         - The total revenue from all orders (Double)
 *         - A dictionary with the number of orders per product category (Map<String, Int>)
 */
fun createOrderHistory(orders: Map<String, Map<String, Any>>): Triple<Int, Double, Map<String, Int>> {

    var numOrders = orders.size
    var totalRevenue = 0.0
    val ordersPerCategory = mutableMapOf<String, Int>()

    for (order in orders.values) {
        totalRevenue += order["price"] as Double
        val category = order["category"] as String

        ordersPerCategory[category] = ordersPerCategory.getOrDefault(category, 0) + 1
    }

    return Triple(numOrders, totalRevenue, ordersPerCategory)
}

// Example usage
val orders = mapOf(
    "order1" to mapOf("category" to "electronics", "price" to 149.0)
)
/**
 * This function receives a dictionary of order history and returns a tuple containing the number of orders placed,
 * the total revenue, and a dictionary with the number of orders per product category.
 *
 * @param orders A dictionary with the order history, where the keys are the order IDs and the values are
 *               dictionaries with the order details.
 * @return A tuple containing:
 *         - The number of orders placed (Int)
 *         - The total revenue from all orders (Double)
 *         - A dictionary with the number of orders per product category (Map<String, Int>)
 */
fun createOrderHistory(orders: Map<String, Map<String, Any>>): Triple<Int, Double, Map<String, Int>> {
/**
 * This function receives a dictionary of order history and returns a tuple containing the number of orders placed,
 * the total revenue, and a dictionary with the number of orders per product category.
 *
 * @param orders A dictionary with the order history, where the keys are the order IDs and the values are
 *               dictionaries with the order details.
 * @return A tuple containing:
 *         - The number of orders placed (Int)
 *         - The total revenue from all orders (Double)
 *         - A dictionary with the number of orders per product category (Map<String, Int>)
 */
fun createOrderHistory(orders: Map<String, Map<String, Any>>): Triple<Int, Double, Map<String, Int>> {

    var numOrders = orders.size
    var totalRevenue = 0.0
    val ordersPerCategory = mutableMapOf<String, Int>()

    for (order in orders.values) {
        totalRevenue += order["price"] as Double
        val category = order["category"] as String

        ordersPerCategory[category] = ordersPerCategory.getOrDefault(category, 0) + 1
    }

    return Triple(numOrders, totalRevenue, ordersPerCategory)
}

// Example usage
val orders = mapOf(
    "order1" to mapOf("category" to "electronics", "price" to 149.0)
)