# Problem Description
This is a clock-like mechanism problem where:
- A circular dial has 8 positions numbered 1-8
- A pointer moves according to specific rotation rules based on time t
- The task is to determine which number the pointer indicates at any given time t
- The pointer's movement alternates between clockwise and counterclockwise rotations
- The rotation angle depends on the time step

# Visual Facts
1. Circle Layout:
   - 8 equally spaced positions arranged in a circle
   - Numbers 1-8 arranged clockwise
   - Position 1 is at the top (12 o'clock position)

2. Time Steps Shown:
   - T=0: Points to 1
   - T=1: Points to 2 (45° clockwise)
   - T=2: Points to 8 (90° counterclockwise)
   - T=3: Points to 3 (135° clockwise)
   - T=4: Points to 7 (180° counterclockwise)
   - T=5: Points to 4 (225° clockwise)
   - T=6: Points to 6 (270° counterclockwise)
   - T=7: Points to 5 (315° clockwise)

# Visual Patterns
1. Movement Pattern:
   - Odd t: Clockwise rotation
   - Even t: Counterclockwise rotation

2. Angle Pattern:
   - Rotation angle = 45° × t

3. Position Pattern:
   - the position numbers' array is position_array = [1,2,3,4,5,6,7,8]
   - Suppose the last position was p, and the current time step is t:
      - If t is odd, the new position index = (index(position_array, p) + t) % 8
      - If t is even, the new position index = (index(position_array, p) - t) % 8
      - the new position is position_array[new_position_index]
   - To get the final position at t, calculate the position step-by-step for each time step untill t

# Solution
def solution(t: int) -> int:
    """
    Returns the number that the pointer indicates at the given time t.

    Parameters:
        t (int): The current time

    Returns:
        int: The number that the pointer indicates
    """
    pos = 1
    for i in range(1,t+1):
        d =  i * (-1 if i%2==0 else 1) % 8
        inter_pos = ( d + pos ) % 8 
        pos = inter_pos if inter_pos != 0 else 8
    return pos    


# Test Script
def test():
    test_cases = [
        (0,1),
        (1,2),
        (5,4),
        (7,5),
        (8,5),
        (12,3),
        (21,4),
        (25,6),
        (100,7),
    ]
    for t, expected_output in test_cases:
        try:
            output = solution(t)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`t`: {t}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

        if output != expected_output:
            error_message = (
                f"The following Test Case failed:\n"
                f"`t`: {t}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {expected_output}"
            )
            assert False, error_message

test()