def reverse_direction(heading: int) -> int:
    """
    Inverts a direction in degrees

    Args:
        heading: original direction

    Returns: direction plus or minus 180°

    """
    if heading >= 180:
        return int(heading - 180)

    return int(heading + 180)