/**
 * Given a farm_data representing a matrix of crops, modify the elements in the given rows and columns according to the following rules:
 *
 * - If the crop is 'wheat', replace it with 'corn'
 * - If the crop is 'corn', replace it with 'carrot'
 * - If the crop is 'carrot', replace it with 'wheat'
 *
 * @param farmData The matrix containing the crops data.
 * @param rows The row indices to modify.
 * @param columns The column indices to modify.
 * @return The modified farmData matrix.
 */
fun modifyFarmCrops(farmData: Array<Array<String>>, rows: List<Int>, columns: List<Int>): Array<Array<String>> {

    for (row in rows) {
        for (column in columns) {
            val crop = farmData[row][column]

            farmData[row][column] = when (crop) {
                "wheat" -> "corn"
                "corn" -> "carrot"
                "carrot" -> "wheat"
                else -> crop
            }
        }
    }

    return farmData
}

// Example usage
val farmData = arrayOf(
    arrayOf("wheat", "corn"),
    arrayOf("corn", "carrot")
)

val modifiedFarmData = modifyFarmCrops(farmData, listOf(0), listOf(1))
/**
 * Given a farm_data representing a matrix of crops, modify the elements in the given rows and columns according to the following rules:
 *
 * - If the crop is 'wheat', replace it with 'corn'
 * - If the crop is 'corn', replace it with 'carrot'
 * - If the crop is 'carrot', replace it with 'wheat'
 *
 * @param farmData The matrix containing the crops data.
 * @param rows The row indices to modify.
 * @param columns The column indices to modify.
 * @return The modified farmData matrix.
 */
fun modifyFarmCrops(farmData: Array<Array<String>>, rows: List<Int>, columns: List<Int>): Array<Array<String>> {
/**
 * Given a farm_data representing a matrix of crops, modify the elements in the given rows and columns according to the following rules:
 *
 * - If the crop is 'wheat', replace it with 'corn'
 * - If the crop is 'corn', replace it with 'carrot'
 * - If the crop is 'carrot', replace it with 'wheat'
 *
 * @param farmData The matrix containing the crops data.
 * @param rows The row indices to modify.
 * @param columns The column indices to modify.
 * @return The modified farmData matrix.
 */
fun modifyFarmCrops(farmData: Array<Array<String>>, rows: List<Int>, columns: List<Int>): Array<Array<String>> {

    for (row in rows) {
        for (column in columns) {
            val crop = farmData[row][column]

            farmData[row][column] = when (crop) {
                "wheat" -> "corn"
                "corn" -> "carrot"
                "carrot" -> "wheat"
                else -> crop
            }
        }
    }

    return farmData
}

// Example usage
val farmData = arrayOf(
    arrayOf("wheat", "corn"),
    arrayOf("corn", "carrot")
)

val modifiedFarmData = modifyFarmCrops(farmData, listOf(0), listOf(1))