# Problem Description
This problem involves transforming an initial sequence of characters based on a given pointer position. The transformation follows specific rules where the elements before the pointer position (inclusive) are cyclically shifted. The goal is to determine the final sequence after applying these transformation rules.

# Visual Facts
1. Example 1 shows:
   - Initial sequence "ABC" with pointer at position 3
   - Step-by-step transformation through multiple stages
   - Final sequence is "BCA"
   - Each step shows movement of elements with arrows
   - Uses boxes to represent positions (1,2,3)
2. Example 2 shows:
   - Generalized case with sequence "1,2,...,i,i+1,...,N"
   - Pointer starts at position i
   - Final Sequence: "2, 3, ..., i, 1, i+1, ..., N"
   - Similar box representation for positions


# Visual Patterns
1. **Movement Pattern:**
   - The elements before the pointer position (inclusive) undergo a cyclic shift.
   - The first element of the subsequence before the pointer moves to the last.
   - Other elements shift left by one position.
   - Elements before the pointer remain unchanged.

2. **Transformation Rules:**
   - For a sequence of length N and pointer at position i(1-indexed):
     * Elements [i+1:N] stay unchanged.
     * Elements [1:i] are transformed by moving the fist element to the last.
     * Final sequence = original[2:i] + [first_element] + original[i+1:-1]

3. **Position Rules:**
   - Uses 1-based indexing for pointer position.
   - Valid pointer positions are between 1 and the length of the sequence.
   - The transformation preserves the total length of the sequence.

4. **Cyclic Pattern:**
   - The transformation involves a cyclic shift of elements after the pointer.
   - Only the subsequence before (and including) the pointer position is affected.
   - The shift is always by one position, with the first element moving to the last of its subsequence.


# Solution
from typing import List

def solution(init_seq: List[str], ptr_pos: int) -> List[str]:
    """
    Transforms an initial sequence based on a pointer position according to specific rules.

    Args:
        init_seq: List of single characters representing the initial sequence
        ptr_pos: pointer position (1-based indexing)

    Returns:
        List of single characters representing the transformed sequence
    """
    if not init_seq:
        return []
    seq_before_ptr = init_seq[:ptr_pos]  
    seq_after_ptr = init_seq[ptr_pos:]


    if seq_before_ptr:
        seq_before_ptr_transformed = seq_before_ptr[1:] + [seq_before_ptr[0]]
    else:
        seq_before_ptr_transformed = []
    return seq_before_ptr_transformed + seq_after_ptr


# Test Script
def test():
    test_cases = [
        {
            "input": (["A", "B", "C"], 1),
            "expected": ['A', 'B', 'C']
        },
        {
            "input": (["A", "B", "C"], 2),
            "expected": ['B', 'A', 'C']
        },
        {
            "input": (["A", "B", "C"], 3),
            "expected": ['B', 'C', 'A']
        },
        {
            "input": (["A"], 1),
            "expected": ['A']
        },
        {
            "input": (["A", "B"], 1),
            "expected": ['A', 'B']
        },
        {
            "input": (["A", "B", "C", "D"], 2),
            "expected": ['B', 'A', 'C', 'D']     
        },
        {
            "input": (["1", "2", "3", "4", "5"], 4),
            "expected": ['2', '3', '4', '1', '5']
        },
        {
            "input": (["1", "2", "3", "4", "5"], 3),
            "expected": ['2', '3', '1', '4', '5']
        },
        {
            "input": (["1", "2", "3", "4", "5"], 2),
            "expected": ['2', '1', '3', '4', '5']
        },
        {
            "input": (["1", "2", "3", "4", "5"], 1),
            "expected":['1', '2', '3', '4', '5']
        },

    ]
    
    for i, test_case in enumerate(test_cases):
        init_seq, ptr_pos = test_case["input"]
        expected = test_case["expected"]
        
        try:
            output = solution(init_seq, ptr_pos)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`init_seq`: {init_seq}\n" 
                f"`ptr_pos`: {ptr_pos}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message
            
        if output != expected:
            error_message = (
                f"The following Test Case failed:\n"
                f"`init_seq`: {init_seq}\n"
                f"`ptr_pos`: {ptr_pos}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {expected}"
            )
            assert False, error_message

test()