提交 43d2fe07 编写于 作者: 初学者联盟's avatar 初学者联盟

更新叠罗汉4x4/横向叠罗汉.py, 叠罗汉4x4/VIP_module1.py

上级
def MAXorMIN(Max_or_Min:type[str],_list:type[list])->int|None:
try:
if Max_or_Min=='Max':
return max(tuple(_list))
elif Max_or_Min=='Min':
return min(tuple(_list))
except:
return None
def str_in_list2int_in_list(_list:type[list])->list|None:
try:
New_list=[]
for i in _list:
New_list.append(int(i))
return New_list
except:
return None
def Tfote(_list:type[list],element)->int|None:
for i in range(len(_list)):
if _list[i]==element:
return i+1
break
def print_xy_list(_list:type[list])->None:
for i in range(len(_list)):
print('第%d行: '%(i+1),end='')
for j in _list[i]:
print(j,end=' ')
print('')
#print_xy_list([[1,2,3],[2,2,3],[3,2,3]])#实验
#print(MAXorMIN('Min',[23,34,45,12]))#实验
def _01(_int:type[int])->str|None:
if _int<10:
return '0'+str(_int)
elif 10<=_int<100:
return str(_int)
\ No newline at end of file
import VIP_module1 as VM
a=[[' ',' ',' ',' '],[' ',' ',' ',' '],[' ',' ',' ',' '],[' ',' ',' ',' ']]
b=[0,0,0,0]
c=['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16']
z=0
while True:
z+=1
if c==[]:
print('你胜利了,你的结果是:')
VM.print_xy_list(a)
print('你用了%d次。'%z)
break
d=VM.MAXorMIN('Min',VM.str_in_list2int_in_list(c))
VM.print_xy_list(a)
e=int(input('行数(1~4),要放"'+str(d)+'": '))
if b[e-1]==0:
a[e-1][0]=c[VM.Tfote(VM.str_in_list2int_in_list(c),d)-1]
b[e-1]+=d
c.remove(VM._01(d))
else:
if b[e-1]<d:
for i in a[e-1]:
if i!=' ':
c.append(i)
a[e-1]=[VM._01(d),' ',' ',' ']
c.remove(VM._01(d))
b[e-1]=d
elif VM.Tfote(a[e-1],' ')==None:
print('UNKNOWN ERROR: THE FORMAT IS OUT OF RANGE.')
break
else:
a[e-1][VM.Tfote(a[e-1],' ')-1]=VM._01(d)
b[e-1]+=d
c.remove(VM._01(d))
input('')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册