def genMod(digitnum = 5):
pool = range(digitnum)
# The repeating part must be 3 or multiple of 3
# The repeating part cannot include the last digit
tset = set(range(digitnum-1))
repeats = itertools.combinations(range(digitnum-1), 3)
for r in repeats:
rset = set(r)
oset = tset - rset
for i in r:
pool[i] = '{0}'
odigits = itertools.permutations('0123456789', len(oset))
for o in odigits:
idx = 0
for i in oset:
pool[i] = o[idx]
idx += 1
for last in ['1','3','7','9']:
pool[-1] = last
if pool[0] != '0':
yield ''.join(pool)
评论列表
文章目录