/**
 * Given a list of voltages and two specified voltages, this function replaces all occurrences
 * of the oldVoltage in the voltages list with the newVoltage using list transformations.
 *
 * @param voltages A list of voltages.
 * @param oldVoltage The voltage to be replaced.
 * @param newVoltage The voltage to replace the oldVoltage.
 * @return A new list of voltages with the replacements.
 *
 * Examples:
 * Replacement of voltages:
 * replaceVoltage(listOf(120, 240, 480, 240, 208, 480), 240, 400)
 * Output: [120, 400, 480, 400, 208, 480]
 */
fun replaceVoltage(voltages: List<Int>, oldVoltage: Int, newVoltage: Int): List<Int> {

    return voltages.map { if (it == oldVoltage) newVoltage else it }
}
/**
 * Given a list of voltages and two specified voltages, this function replaces all occurrences
 * of the oldVoltage in the voltages list with the newVoltage using list transformations.
 *
 * @param voltages A list of voltages.
 * @param oldVoltage The voltage to be replaced.
 * @param newVoltage The voltage to replace the oldVoltage.
 * @return A new list of voltages with the replacements.
 *
 * Examples:
 * Replacement of voltages:
 * replaceVoltage(listOf(120, 240, 480, 240, 208, 480), 240, 400)
 * Output: [120, 400, 480, 400, 208, 480]
 */
fun replaceVoltage(voltages: List<Int>, oldVoltage: Int, newVoltage: Int): List<Int> {
/**
 * Given a list of voltages and two specified voltages, this function replaces all occurrences
 * of the oldVoltage in the voltages list with the newVoltage using list transformations.
 *
 * @param voltages A list of voltages.
 * @param oldVoltage The voltage to be replaced.
 * @param newVoltage The voltage to replace the oldVoltage.
 * @return A new list of voltages with the replacements.
 *
 * Examples:
 * Replacement of voltages:
 * replaceVoltage(listOf(120, 240, 480, 240, 208, 480), 240, 400)
 * Output: [120, 400, 480, 400, 208, 480]
 */
fun replaceVoltage(voltages: List<Int>, oldVoltage: Int, newVoltage: Int): List<Int> {

    return voltages.map { if (it == oldVoltage) newVoltage else it }
}