예제 #1
0
def rightTruncates(q):
    ''' rightTruncates(int) -> iterator  yield all the right truncates of a number, e.g. 123 returns 23, 3
    but 101 returns only 1'''
    while q > 9:
        # need to recompute the number of digits in case on contained 0
        q %= 10 ** (numberOfDigits(q) - 1)
        yield q
예제 #2
0
def iCyclicShifts(n):
	''' Generates all cyclic shift, but doesn't yield n'''
	shift = cyclicShift(n)
	m = numberOfDigits(n) - 1
	while shift != n:
		yield shift
		shift = shift//10 + (shift % 10)*10**m