이때부터는 2~8번의 내용을 반복해야한다.
while n * n >= count and rowStart <= rowEnd :
for i in range(rowStart, columnEnd):
snail[rowStart][i] = count
count = count + 1
# 열을 바꿔주기 위해서
rowStart = rowStart + 1
for i in range(rowStart, rowEnd):
snail[i][columnEnd-1] = count
count = count + 1
columnEnd = columnEnd - 1
for i in range(columnEnd-1, columnStart-1, -1):
snail[rowEnd -1][i] = count
count = count + 1
rowEnd = rowEnd -1
for i in range(rowEnd-1, rowStart-1, -1):
snail[i][columnStart] = count
count = count + 1
columnStart = columnStart +1
print("#{}".format(test_case))
for row in snail:
for column in row:
print(column, end=" ")
print()
2시간 소요 : row, column 변화를 수기로 체크해가면서 하느라 늦었다.
나선형 순회 알고리즘 공부로 늦었다. 나선형 순회알고리즘은 너무 어려워서 이해한 다음, 그 다음 포스팅에서 공부한 내용을 정리하고자한다.