/**
 * This function calculates the total number of animals on a farm and returns those that belong to the Farmer.
 * The Farmer's animals include pigs and ducks.
 * The function uses the XOR operator and loop control statements to solve the exercise.
 */
fun farmerHarvest(pigs: Int, cows: Int, chickens: Int, ducks: Int): Int {

    // Total number of animals on the farm
    val totalAnimals = pigs + cows + chickens + ducks

    var farmerAnimals = 0  // Counter for Farmer's animals

    // Loop to iterate over all animals on the farm
    for (animal in 0 until totalAnimals) {
        // XOR operator to check if the animal is either a pig or duck but not both
        if ((animal == pigs && animal != ducks) || (animal != pigs && animal == ducks)) {
            farmerAnimals++  // Increment the counter for Farmer's animals by 1
        }
    }

    return farmerAnimals
}
/**
 * This function calculates the total number of animals on a farm and returns those that belong to the Farmer.
 * The Farmer's animals include pigs and ducks.
 * The function uses the XOR operator and loop control statements to solve the exercise.
 */
fun farmerHarvest(pigs: Int, cows: Int, chickens: Int, ducks: Int): Int {
/**
 * This function calculates the total number of animals on a farm and returns those that belong to the Farmer.
 * The Farmer's animals include pigs and ducks.
 * The function uses the XOR operator and loop control statements to solve the exercise.
 */
fun farmerHarvest(pigs: Int, cows: Int, chickens: Int, ducks: Int): Int {

    // Total number of animals on the farm
    val totalAnimals = pigs + cows + chickens + ducks

    var farmerAnimals = 0  // Counter for Farmer's animals

    // Loop to iterate over all animals on the farm
    for (animal in 0 until totalAnimals) {
        // XOR operator to check if the animal is either a pig or duck but not both
        if ((animal == pigs && animal != ducks) || (animal != pigs && animal == ducks)) {
            farmerAnimals++  // Increment the counter for Farmer's animals by 1
        }
    }

    return farmerAnimals
}