/**
 * Given a list of pairs representing a farmer's inventory, modify the quantity of a specific item at the given index.
 *
 * @param farmInventory A list of pairs representing the farmer's inventory. Each pair contains an item name and its quantity.
 * @param itemIndex The index of the item in the list of pairs that needs to be modified.
 * @param newQuantity The new quantity to be set for the specified item.
 * @return The modified farm inventory list.
 *
 * Example:
 * farmInventory = listOf(Pair("apples", 10), Pair("corn", 15), Pair("eggs", 20))
 * modifyFarmInventory(farmInventory, 1, 5) // Output: [(apples, 10), (corn, 5), (eggs, 20)]
 */
fun modifyFarmInventory(farmInventory: MutableList<Pair<String, Int>>, itemIndex: Int, newQuantity: Int): List<Pair<String, Int>> {

    if (itemIndex >= 0 && itemIndex < farmInventory.size) {
        val (itemName, _) = farmInventory[itemIndex]
        farmInventory[itemIndex] = Pair(itemName, newQuantity)
    }
    return farmInventory
}
/**
 * Given a list of pairs representing a farmer's inventory, modify the quantity of a specific item at the given index.
 *
 * @param farmInventory A list of pairs representing the farmer's inventory. Each pair contains an item name and its quantity.
 * @param itemIndex The index of the item in the list of pairs that needs to be modified.
 * @param newQuantity The new quantity to be set for the specified item.
 * @return The modified farm inventory list.
 *
 * Example:
 * farmInventory = listOf(Pair("apples", 10), Pair("corn", 15), Pair("eggs", 20))
 * modifyFarmInventory(farmInventory, 1, 5) // Output: [(apples, 10), (corn, 5), (eggs, 20)]
 */
fun modifyFarmInventory(farmInventory: MutableList<Pair<String, Int>>, itemIndex: Int, newQuantity: Int): List<Pair<String, Int>> {
/**
 * Given a list of pairs representing a farmer's inventory, modify the quantity of a specific item at the given index.
 *
 * @param farmInventory A list of pairs representing the farmer's inventory. Each pair contains an item name and its quantity.
 * @param itemIndex The index of the item in the list of pairs that needs to be modified.
 * @param newQuantity The new quantity to be set for the specified item.
 * @return The modified farm inventory list.
 *
 * Example:
 * farmInventory = listOf(Pair("apples", 10), Pair("corn", 15), Pair("eggs", 20))
 * modifyFarmInventory(farmInventory, 1, 5) // Output: [(apples, 10), (corn, 5), (eggs, 20)]
 */
fun modifyFarmInventory(farmInventory: MutableList<Pair<String, Int>>, itemIndex: Int, newQuantity: Int): List<Pair<String, Int>> {

    if (itemIndex >= 0 && itemIndex < farmInventory.size) {
        val (itemName, _) = farmInventory[itemIndex]
        farmInventory[itemIndex] = Pair(itemName, newQuantity)
    }
    return farmInventory
}