/**
 * Calculate the fuel consumption for each flight based on the given flight data.
 *
 * @param flightData A dictionary containing the flight data for each aircraft.
 * @return A dictionary containing the fuel consumption for each flight.
 */
fun calculateFuelConsumption(flightData: Map<String, Map<String, Any>>): Map<String, Any> {

    val fuelConsumption = mutableMapOf<String, Any>()

    for ((aircraft, data) in flightData) {
        val initialFuel = data["initial_fuel"] as Int
        val finalFuel = data["final_fuel"] as Int
        val distance = data["distance"] as Int

        // Calculate the fuel consumption using ternary operator
        fuelConsumption[aircraft] = if (finalFuel - initialFuel >= 0) finalFuel - initialFuel else "Negative fuel consumption"

        // Modify the fuel consumption based on distance traveled
        when {
            distance >= 1000 -> fuelConsumption[aircraft] = (fuelConsumption[aircraft] as Int).times(1.1)
            distance >= 500 -> fuelConsumption[aircraft] = (fuelConsumption[aircraft] as Int).times(1.05)
            else -> fuelConsumption[aircraft] = (fuelConsumption[aircraft] as Int).times(1.02)
        }
    }

    return fuelConsumption
}
/**
 * Calculate the fuel consumption for each flight based on the given flight data.
 *
 * @param flightData A dictionary containing the flight data for each aircraft.
 * @return A dictionary containing the fuel consumption for each flight.
 */
fun calculateFuelConsumption(flightData: Map<String, Map<String, Any>>): Map<String, Any> {
/**
 * Calculate the fuel consumption for each flight based on the given flight data.
 *
 * @param flightData A dictionary containing the flight data for each aircraft.
 * @return A dictionary containing the fuel consumption for each flight.
 */
fun calculateFuelConsumption(flightData: Map<String, Map<String, Any>>): Map<String, Any> {

    val fuelConsumption = mutableMapOf<String, Any>()

    for ((aircraft, data) in flightData) {
        val initialFuel = data["initial_fuel"] as Int
        val finalFuel = data["final_fuel"] as Int
        val distance = data["distance"] as Int

        // Calculate the fuel consumption using ternary operator
        fuelConsumption[aircraft] = if (finalFuel - initialFuel >= 0) finalFuel - initialFuel else "Negative fuel consumption"

        // Modify the fuel consumption based on distance traveled
        when {
            distance >= 1000 -> fuelConsumption[aircraft] = (fuelConsumption[aircraft] as Int).times(1.1)
            distance >= 500 -> fuelConsumption[aircraft] = (fuelConsumption[aircraft] as Int).times(1.05)
            else -> fuelConsumption[aircraft] = (fuelConsumption[aircraft] as Int).times(1.02)
        }
    }

    return fuelConsumption
}