def rotate(pattern, k):
    """ Return a left circular rotation of the given pattern by k."""
    if not type(k) == int:
        raise TypeError("Second argument must be an integer")
    n = len(pattern)
    k = k % n
    return pattern[k:n] + pattern[0:k]