def cardinal_direction(b):
    """ Calculate the cardinal direction for a given bearing.

    Ex: 0 is 'North

    Args:
        b: bearing (in degrees)

    Returns:
        A string representing cardinal direction
    """
    dirs = ["North", "North-East", "East", "South-East", "South", "South-West", "West", 
        "North-West"]

    degree = 337.5

    for dir in dirs:
        if b >= degree and b < degree + 45:
            return dir

        if degree + 45 >= 360:
            degree = 22.5
        else:
            degree += 45
    
    return None