/**
 * Given the dancer's initial position and a list of positions to move to, return the final position.
 */
fun move(dancer: Int, position: String): Int {

    // Convert the number line representation to a list of integers
    val positions = position.split(",").map { it.toInt() }

    // Store the initial position
    var currentPos = dancer

    // Iterate over each position to move to
    for (pos in positions) {
        // Calculate the difference between the current position and the target position
        val diff = pos - currentPos

        // Determine the direction to move (left or right) based on the sign of the difference
        val direction = if (diff < 0) "left" else "right"

        // Absolute value of the difference represents the number of steps to take
        val steps = Math.abs(diff)

        // Move the dancer to the target position
        repeat(steps) {
            if (direction == "left") {
                currentPos -= 1
            } else {
                currentPos += 1
            }
        }
    }

    // Return the final position of the dancer
    return currentPos
}
/**
 * Given the dancer's initial position and a list of positions to move to, return the final position.
 */
fun move(dancer: Int, position: String): Int {
/**
 * Given the dancer's initial position and a list of positions to move to, return the final position.
 */
fun move(dancer: Int, position: String): Int {

    // Convert the number line representation to a list of integers
    val positions = position.split(",").map { it.toInt() }

    // Store the initial position
    var currentPos = dancer

    // Iterate over each position to move to
    for (pos in positions) {
        // Calculate the difference between the current position and the target position
        val diff = pos - currentPos

        // Determine the direction to move (left or right) based on the sign of the difference
        val direction = if (diff < 0) "left" else "right"

        // Absolute value of the difference represents the number of steps to take
        val steps = Math.abs(diff)

        // Move the dancer to the target position
        repeat(steps) {
            if (direction == "left") {
                currentPos -= 1
            } else {
                currentPos += 1
            }
        }
    }

    // Return the final position of the dancer
    return currentPos
}