# Problem Description
This is a string processing problem where we need to calculate the total cost of forming a target string using a circular disk mechanism. The disk contains lowercase letters (a-z) and a special 'check' character arranged in a circle. We need to select each character of the target string by rotating to it and then confirming by rotating back to 'check', accumulating costs for all rotations.

# Visual Facts
1. The disk has 27 positions (26 letters + 1 'check' character)
2. Letters are arranged alphabetically clockwise from 'a' to 'z'
3. The 'check' character is positioned between 'a' and 'z'
4. Two examples are provided:
   - Example 1: target="h", total cost=27 (8+19)
   - Example 2: target="jay", total cost=81 (10+17+1+26+2+25)
5. Each move shows two steps:
   - Step 1: From 'check' rotate to target letter
   - Step 2: Rotate back to 'check'
6. The pointer always starts at 'check' position
7. Movement can be only clockwise.

# Visual Patterns
1. Movement Cost Pattern: 
   - The pointer moves along the disk in the clockwise direction. 
   - The “cost” is the number of steps passed. For example, rotating from **a** to **b** costs 1, and from **a** to **z** costs 25.

2. Operation Pattern:
   - For each character in target string:
     1. Move from 'check' to character (cost X)
     2. Move back to 'check' (cost X)
     3. Repeat for next character

3. Cost Calculation Pattern:
   - Example 1: "h" costs 8 steps to reach + 19 steps back = 27
   - Example 2: "jay" breaks down as:
     * j: 10 steps to reach + 17 steps back = 27
     * a: 1 steps to reach + 26 steps back = 27
     * y: 2 steps to reach + 25 steps back = 27
     * Total = 81

4. Optimization Pattern:
   - Always choose the clockwise path.
   - The cost for each step is the minimum distance between current position and target position on the circular disk

# Solution
def solution(target: str) -> int:
    """
    Calculates the cost of a target string according to defined rules.

    Args:
        target: The input string to calculate cost for

    Returns:
        The total cost as an integer
    """
    return len(target) * 27


# Test Script

def test():
    test_cases = [
        {"input": "a", "expected": 27},
        {"input": "abc", "expected": 81},
        {"input": "az", "expected": 54},
        {"input": "jay", "expected": 81},
        {"input": "zaz", "expected": 81}, 
        {"input": "humanevalv", "expected": 270},
        {"input": "paperaccepted", "expected": 351},
        {"input": "abcdefghijklmnopqrstuvwxyz", "expected": 702},
        {"input": "davidtao", "expected": 216},
        {"input": "icmlaccepted", "expected": 324},
    ]

    for i, test_case in enumerate(test_cases, start=1):
        target = test_case["input"]
        expected_output = test_case["expected"]

        try:
            output = solution(target)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`target`: {target}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

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

test()