Shift the Score Ladder
Context
A player’s level scores are recorded in order along a score ladder. After a special move, the ladder advances cyclically: the requested number of leading scores moves to the end, while every score keeps its original cyclic order. Very large move counts may represent repeated full turns.
Problem
Write a function that cyclically shifts a sequence of level scores to the left by the requested number of moves. A left shift moves the first score to the end, repeating this for the displacement amount. A displacement equal to the sequence length changes nothing, and larger displacements wrap around as if complete turns had been removed. If the sequence is empty, return an empty sequence. Preserve every score exactly once, including repeated scores, and keep the relative order within each moved segment.
Examples
moves = 2scores = [10, 20, 30, 40, 50][30, 40, 50, 10, 20]moves = 5scores = [7, 7, 12, 19][7, 12, 19, 7]moves = 0scores = [3, 8, 15, 21, 34, 55][3, 8, 15, 21, 34, 55]Constraints
0 <= len(scores) <= 1000000 <= scores[i] <= 1000000 for every i0 <= moves <= 1000000000- Types:
scoresis int[],movesis int; result is int[]
Function signature
def shift_score_ladder(scores: list[int], moves: int) -> list[int]
scoreslist[int]- The level scores in their current order.
movesint- The nonnegative number of leftward cyclic moves.
- returns list[int]
- The scores after the cyclic shift, with the suffix after the effective split placed before the prefix.
Adapted from MBPP problem task_328 (CC BY 4.0). Rewritten, extended and verified by Iksha.
Notes
- The input sequence may be empty and may contain repeated values.
- The result should use proportional extra space and linear time.