파아랑새 2018. 4. 27. 15:56
import time
import os
import random
import pprint as ppr
# 명단 리스트 섞기
def stuDataRandom(stuList):
random.shuffle(stuList)
def menuFunction():
print ("============================")
print ("자리 배정을 시작하겠습니다.")
print ("============================")
time.sleep(3)
os.system("cls")
print ("============================")
print ("모두 경건한 마음으로 지켜봐주시기 바랍니다.")
print ("============================")
time.sleep(3)
os.system("cls")
print ("============================")
print ("Good luck ~!")
print ("============================")
time.sleep(3)
os.system("cls")

def student(stuList):
retIndex = random.randint(0, len(stuList)-1)
return retIndex

def main():
stuName = ["이은지","길기철","이건홍","조효석","조예지",
"오성호","박승우","김대성","정규원","장용하",
"임승연","김서연","김홍기","강주인","채민지",
"최민지","이진용","박준열","조상원","고동하",
"박성준","김휘수","김수이","한지혜","조현우",
"유혁 ","정지웅"]
stuDataRandom(stuName)
newList = []
seat = [["empty" for _ in range(8)] for i in range(4)]

#ppr.pprint (seat)
seatIndex = {0:[i for i in range(8)],
1:[i for i in range(8)],
2:[i for i in range(8)],
3:[2,3,4,5,6]}
menuFunction() #--------- 메뉴 호출
testList = []

while True:
if len(stuName) != 0:
index = student(stuName)
#print (stuName[index])
newList.append(stuName[index])
# 삭제
stuName.pop(index)
else:
break

rowSeat = [x for x in seatIndex.keys()]
x = 0
while True:
r_ = rowSeat[random.randint(0, len(rowSeat)-1)]
c_ = seatIndex[r_][random.randint(0, len(seatIndex[r_])-1)]
#print (r_, c_)
try:
seat[r_][c_] = newList[x]
except:
break
else:
print ("front ---------------------")
for i in range(0,4):
for j in range(0, 8):
print (seat[i][j], end=" ")
print ()
print ("back ---------------------")
x += 1
time.sleep(3)
os.system("cls")
seatIndex[r_].remove(c_)
if seatIndex[r_] == []:
rowSeat.remove(r_)
del seatIndex[r_]
if seatIndex == {}:
break
if __name__ == "__main__":
main()