#coding=gbk
#[9,10,11],[9,10,12],[9,11,12],[10,11,12]
def 顺序数判断(lst):
i=0
t=1
while True:
try:
if lst[i]<lst[i+1]:
t+=1
i+=1
else:
break
except:
break
if t==len(lst):
return True
else:
return False
#n=2,max=4:01,02,03,04,12,13,14,23,24,34
#n=3,max=4:012,013,014,023,024,034
def 组合(几个数字,最大数字): #n就是数位,max就是多少进制
def 复制列表(lst1,lst2):
lst1=[]
for i in range(len(lst2)):
lst1.append(lst2[i])
return lst1
lst=[]
totallst=[]
for _ in range(几个数字):
lst.append(0) #先全部0初始化
# print(lst)
while True:
lst[-1]+=1
if 最大数字 in lst: #进位
t=lst.index(最大数字)
if t==0:
break
lst[t]=0
lst[t-1]+=1
if 最大数字 not in lst and 顺序数判断(lst):
print(lst)
newlist=复制列表([],lst)
totallst.append(newlist)
print(totallst)
print(f'共有{len(totallst)}个')
组合(4,6)