어제보다 더 나은 나

구름LEVEL_빙글빙글1(별2개)_답 본문

코딩테스트/문제풀이

구름LEVEL_빙글빙글1(별2개)_답

확인해볼까 2022. 5. 3. 17:49
N = int(input())
M = N

x = int(0)
y = int(0)

matrix = [[0] * 2 * N for _ in range(N)]

# print(matrix)

for i in range(N):
    if i % 4 == 0:
        if i == 0:
            for j in range(M):
                k = 2 * j
                matrix[x][y + k] = 1

            x = i % 4
            y = k

            M = M - 1

            x = i % 4
            y = k

        else:
            for j in range(1, M + 1):
                k = 2 * j
                matrix[x][y + k] = 1

            x = x
            y = y + 2 * M

            M = M - 2

    # print(f"{i} : {x}, {y}")

    elif i % 4 == 1:
        for j in range(1, M + 1):
            matrix[x + j][y] = 1

        x = x + M
        y = y


    # print(f"{i} : {x}, {y}")

    elif i % 4 == 2:
        for j in range(1, M + 1):
            o = 2 * j
            matrix[x][y - o] = 1

        x = x
        y = y - o

        M = M - 2


    # print(f"{i} : {x}, {y}")

    elif i % 4 == 3:
        for j in range(1, M + 1):
            o = j
            matrix[x - j][y] = 1

        x = x - M
        y = y

        M = M

    # print(f"{i} : {x}, {y}")

for i in range(N):
    for j in range(2 * N):
        if matrix[i][j] == 1:
            matrix[i][j] = '#'
        elif matrix[i][j] == 0:
            matrix[i][j] = ' '

for i in matrix:
    for j in i:
        print(j, end='')
    print()




'코딩테스트 > 문제풀이' 카테고리의 다른 글

백준_1316번_그룹단어체커  (0) 2022.05.13
백준_1075번_나누기  (0) 2022.05.12
구름LEVEL_화학물질  (0) 2022.05.10
구름LEVEL_파도 센서(별1개)_답  (0) 2022.05.06
구름LEVEL_인공지능청소기(별1개)_답  (0) 2022.05.04
Comments