양옆의 숫자가 동일하면 가운데에 있는 세포의 상태가 변경되도록 구현
def nextGen(curList):
nextList = curList.copy()
for i in range(len(curList)):
pre_i = i-1
next_i = i+1
if next_i == len(curList):
next_i = 0
if currentList[pre_i] == currentList[next_i]:
nextList[i] = currentList[i]
else:
if curList[i] == '0':
nextList[i] = '1'
else:
nextList[i] = '0'
return nextList
start = input("초기패턴입력 :")
currentList = list(start)
while True:
print("현재상태 :")
print(currentList)
userInput = input("다음세대 y/n :")
if userInput == "y":
currentList = nextGen(currentList)
else:
print("The End")
break
