/**
 * A dancer is performing a series of moves. The dancer can move distance steps forward or backward by using
 * the left shift operator '<<' or the right shift operator '>>'. Implement the code to calculate the position
 * of the dancer after performing a series of steps.
 *
 * @param distance The initial position of the dancer.
 * @param steps A list of steps the dancer must perform. Each step is represented by a tuple (direction, amount)
 *              where 'direction' is either 'forward' or 'backward' and 'amount' is the number of steps.
 * @return The final position of the dancer.
 *
 * Example:
 * dancerMoves(10, listOf(Pair("forward", 2), Pair("backward", 5), Pair("forward", 3), Pair("backward", 1)))
 * Output: 6
 */
fun dancerMoves(distance: Int, steps: List<Pair<String, Int>>): Int {

    var currentPosition = distance

    for (step in steps) {
        val (direction, amount) = step
        if (direction == "forward") {
            currentPosition = currentPosition shl amount
        } else if (direction == "backward") {
            currentPosition = currentPosition shr amount
        }
    }

    return currentPosition
}
/**
 * A dancer is performing a series of moves. The dancer can move distance steps forward or backward by using
 * the left shift operator '<<' or the right shift operator '>>'. Implement the code to calculate the position
 * of the dancer after performing a series of steps.
 *
 * @param distance The initial position of the dancer.
 * @param steps A list of steps the dancer must perform. Each step is represented by a tuple (direction, amount)
 *              where 'direction' is either 'forward' or 'backward' and 'amount' is the number of steps.
 * @return The final position of the dancer.
 *
 * Example:
 * dancerMoves(10, listOf(Pair("forward", 2), Pair("backward", 5), Pair("forward", 3), Pair("backward", 1)))
 * Output: 6
 */
fun dancerMoves(distance: Int, steps: List<Pair<String, Int>>): Int {
/**
 * A dancer is performing a series of moves. The dancer can move distance steps forward or backward by using
 * the left shift operator '<<' or the right shift operator '>>'. Implement the code to calculate the position
 * of the dancer after performing a series of steps.
 *
 * @param distance The initial position of the dancer.
 * @param steps A list of steps the dancer must perform. Each step is represented by a tuple (direction, amount)
 *              where 'direction' is either 'forward' or 'backward' and 'amount' is the number of steps.
 * @return The final position of the dancer.
 *
 * Example:
 * dancerMoves(10, listOf(Pair("forward", 2), Pair("backward", 5), Pair("forward", 3), Pair("backward", 1)))
 * Output: 6
 */
fun dancerMoves(distance: Int, steps: List<Pair<String, Int>>): Int {

    var currentPosition = distance

    for (step in steps) {
        val (direction, amount) = step
        if (direction == "forward") {
            currentPosition = currentPosition shl amount
        } else if (direction == "backward") {
            currentPosition = currentPosition shr amount
        }
    }

    return currentPosition
}