/**
 * Given a list of dance moves, this function will perform the moves one by one for the dancer.
 *
 * @param dancerName The name of the dancer.
 * @param danceMoves List of dance moves.
 */
fun dancerMoves(dancerName: String, danceMoves: List<String>) {

    var i = 0
    var dancing = true

    while (dancing && i < danceMoves.size) {
        val move = danceMoves[i]

        when {
            move == "break" -> {
                // Stop dancing if the move is "break"
                println("$dancerName took a break and stopped dancing.")
                break
            }
            move == "spin" && i < danceMoves.size - 1 && danceMoves[i + 1] == "jump" -> {
                // If the current move is "spin" and the next move is "jump", skip the next move
                println("$dancerName spun and skipped a jump.")
                i += 2
            }
            move == "jump" && i > 0 && danceMoves[i - 1] == "spin" -> {
                // If the current move is "jump" and the previous move is "spin", skip this move
                i++
            }
            else -> {
                i++
            }
        }
    }
}
/**
 * Given a list of dance moves, this function will perform the moves one by one for the dancer.
 *
 * @param dancerName The name of the dancer.
 * @param danceMoves List of dance moves.
 */
fun dancerMoves(dancerName: String, danceMoves: List<String>) {
/**
 * Given a list of dance moves, this function will perform the moves one by one for the dancer.
 *
 * @param dancerName The name of the dancer.
 * @param danceMoves List of dance moves.
 */
fun dancerMoves(dancerName: String, danceMoves: List<String>) {

    var i = 0
    var dancing = true

    while (dancing && i < danceMoves.size) {
        val move = danceMoves[i]

        when {
            move == "break" -> {
                // Stop dancing if the move is "break"
                println("$dancerName took a break and stopped dancing.")
                break
            }
            move == "spin" && i < danceMoves.size - 1 && danceMoves[i + 1] == "jump" -> {
                // If the current move is "spin" and the next move is "jump", skip the next move
                println("$dancerName spun and skipped a jump.")
                i += 2
            }
            move == "jump" && i > 0 && danceMoves[i - 1] == "spin" -> {
                // If the current move is "jump" and the previous move is "spin", skip this move
                i++
            }
            else -> {
                i++
            }
        }
    }
}