# 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 (19+5)
   - Example 2: target="jay", total cost=81 (17+10+26+1+25+2)
5. Each move shows two steps:
   - Step 1: From 'check' rotate anti-clockwisely to target letter
   - Step 2: Rotate anti-clockwisely back to 'check'
6. The pointer always starts at 'check' position
7. Movement can be only anticlockwise.

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

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 19 steps to reach + 8 steps back = 27
   - Example 2: "jay" breaks down as:
     * j: 17 steps to reach + 10 steps back = 27
     * a: 26 steps to reach + 1 steps back = 27
     * y: 25 steps to reach + 2 steps back = 27
     * Total = 81

4. Optimization Pattern:
   - Always choose the anticlockwise 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()