def rotate(i, length):
    """Given integer i and number of digits, rotate its digits by 1 spot"""
    s = str(i)
    ans = 0
    if len(s) == 1:
        return i
    if len(s) == 2:
        ans = int(s[1] + s[0])
    else:
        ans = int(s[1:] + s[0])
    while len(str(ans)) < length: #solve for 011 being rotated to 11 instead of 110
        ans *= 10
    return ans