/**
 * Given an image, replaces all pixels that are of a specific color
 * with a new color.
 *
 * @param image A list of tuples representing the pixels in the image.
 *              Each tuple contains the RGB values.
 * @param oldColor A tuple representing the RGB values of the color to be replaced.
 * @param newColor A tuple representing the RGB values of the color to replace the old color.
 * @return A list of tuples representing the modified image with the colors replaced.
 *
 * Example:
 * replaceColors([(255, 0, 0), (0, 255, 0), (0, 0, 255)], (0, 255, 0), (255, 255, 255))
 * Output: [(255, 0, 0), (255, 255, 255), (0, 0, 255)]
 */
fun replaceColors(image: List<Triple<Int, Int, Int>>, oldColor: Triple<Int, Int, Int>, newColor: Triple<Int, Int, Int>): List<Triple<Int, Int, Int>> {

    val modifiedImage = mutableListOf<Triple<Int, Int, Int>>()

    for (pixel in image) {
        if (pixel == oldColor) {
            modifiedImage.add(newColor)
        } else {
            modifiedImage.add(pixel)
        }
    }

    return modifiedImage
}
/**
 * Given an image, replaces all pixels that are of a specific color
 * with a new color.
 *
 * @param image A list of tuples representing the pixels in the image.
 *              Each tuple contains the RGB values.
 * @param oldColor A tuple representing the RGB values of the color to be replaced.
 * @param newColor A tuple representing the RGB values of the color to replace the old color.
 * @return A list of tuples representing the modified image with the colors replaced.
 *
 * Example:
 * replaceColors([(255, 0, 0), (0, 255, 0), (0, 0, 255)], (0, 255, 0), (255, 255, 255))
 * Output: [(255, 0, 0), (255, 255, 255), (0, 0, 255)]
 */
fun replaceColors(image: List<Triple<Int, Int, Int>>, oldColor: Triple<Int, Int, Int>, newColor: Triple<Int, Int, Int>): List<Triple<Int, Int, Int>> {
/**
 * Given an image, replaces all pixels that are of a specific color
 * with a new color.
 *
 * @param image A list of tuples representing the pixels in the image.
 *              Each tuple contains the RGB values.
 * @param oldColor A tuple representing the RGB values of the color to be replaced.
 * @param newColor A tuple representing the RGB values of the color to replace the old color.
 * @return A list of tuples representing the modified image with the colors replaced.
 *
 * Example:
 * replaceColors([(255, 0, 0), (0, 255, 0), (0, 0, 255)], (0, 255, 0), (255, 255, 255))
 * Output: [(255, 0, 0), (255, 255, 255), (0, 0, 255)]
 */
fun replaceColors(image: List<Triple<Int, Int, Int>>, oldColor: Triple<Int, Int, Int>, newColor: Triple<Int, Int, Int>): List<Triple<Int, Int, Int>> {

    val modifiedImage = mutableListOf<Triple<Int, Int, Int>>()

    for (pixel in image) {
        if (pixel == oldColor) {
            modifiedImage.add(newColor)
        } else {
            modifiedImage.add(pixel)
        }
    }

    return modifiedImage
}