다소 어렵게 접근한 느낌이 듭니다.
아래 그림은 제가 어떻게 구현했는지 그림으로 설명을 해줍니다.
원래는 가로로 길게 늘이는 모양이 되어야하는데, 그렇게 구현하면 복잡할 것 같았습니다.
저는 오른쪽으로 90도 회전하고 아래로 출력할 데이터를 추가해주는 방식으로 구현했습니다.
최종적으로 다시 왼쪽으로 90도 회전한 후 출력합니다.
T = int(input())
start = end = ['.', '.', '#', '.', '.']
second = fourth = ['.', '#', '.', '#', '.']
third = ['#', '.', '', '.', '#']
storage = ''
for tc in range(1, 1+T):
string = input().strip()
result = []
# 글자 수만큼 first, second, third, fourth 를 반복적으로 출력할 리스트에 추가합니다.
for i in range(len(string)):
result.append(start)
result.append(second)
tmp = third[:]
# 기존값을 출력할 글자로 대체합니다.
tmp[2] = string[i]
result.append(tmp)
result.append(fourth)
# 마지막에 뚜껑을 닫아줍니다.
result.append(end)
output = [[0] * len(result) for _ in range(len(result[0]))]
# 아래로 길게 늘어진 데이터를 왼쪽으로 90도 회전에서 저장
for r in range(len(result)):
for c in range(len(result[0])):
output[-c-1][r] = result[r][c]
for i in range(len(output)):
storage += ''.join(output[i]) + '\n'
print(storage)