/**
 * Given a dancer object and a list of new coordinates, modify the dancer's coordinates
 * using list methods and ensure floating-point accuracy by considering epsilon.
 *
 * @param dancer A list representing the current coordinates of the dancer.
 * @param newCoordinates A list of new coordinates to modify the dancer's position.
 * @return The modified coordinates of the dancer.
 * @throws IllegalArgumentException If any coordinate value in newCoordinates is not a float.
 */
fun modifyCoordinates(dancer: MutableList<Double>, newCoordinates: List<Double>): List<Double> {

    val epsilon = 1e-9  // A very small value to consider when comparing floating-point numbers

    // Check if all new coordinates are float values, raise an error if any is not
    if (newCoordinates.any { it !is Double }) {
        throw IllegalArgumentException("All newCoordinates must be double values.")
    }

    // Modify the dancer's coordinates using list methods and considering floating-point accuracy
    for (i in dancer.indices) {
        if (Math.abs(dancer[i] - newCoordinates[i]) > epsilon) {
            dancer[i] = newCoordinates[i]
        }
    }

    return dancer
}
/**
 * Given a dancer object and a list of new coordinates, modify the dancer's coordinates
 * using list methods and ensure floating-point accuracy by considering epsilon.
 *
 * @param dancer A list representing the current coordinates of the dancer.
 * @param newCoordinates A list of new coordinates to modify the dancer's position.
 * @return The modified coordinates of the dancer.
 * @throws IllegalArgumentException If any coordinate value in newCoordinates is not a float.
 */
fun modifyCoordinates(dancer: MutableList<Double>, newCoordinates: List<Double>): List<Double> {
/**
 * Given a dancer object and a list of new coordinates, modify the dancer's coordinates
 * using list methods and ensure floating-point accuracy by considering epsilon.
 *
 * @param dancer A list representing the current coordinates of the dancer.
 * @param newCoordinates A list of new coordinates to modify the dancer's position.
 * @return The modified coordinates of the dancer.
 * @throws IllegalArgumentException If any coordinate value in newCoordinates is not a float.
 */
fun modifyCoordinates(dancer: MutableList<Double>, newCoordinates: List<Double>): List<Double> {

    val epsilon = 1e-9  // A very small value to consider when comparing floating-point numbers

    // Check if all new coordinates are float values, raise an error if any is not
    if (newCoordinates.any { it !is Double }) {
        throw IllegalArgumentException("All newCoordinates must be double values.")
    }

    // Modify the dancer's coordinates using list methods and considering floating-point accuracy
    for (i in dancer.indices) {
        if (Math.abs(dancer[i] - newCoordinates[i]) > epsilon) {
            dancer[i] = newCoordinates[i]
        }
    }

    return dancer
}