🗝️ Algorithm/🟩 백준
🟩 [백준] [Python] [Gold5] 2447번_별 찍기 - 10
Dbswnstjd
2023. 4. 21. 09:48
문제
https://www.acmicpc.net/problem/2447
2447번: 별 찍기 - 10
재귀적인 패턴으로 별을 찍어 보자. N이 3의 거듭제곱(3, 9, 27, ...)이라고 할 때, 크기 N의 패턴은 N×N 정사각형 모양이다. 크기 3의 패턴은 가운데에 공백이 있고, 가운데를 제외한 모든 칸에 별이
www.acmicpc.net
풀이
# 백준 2447번 문제 - 별 찍기 10
n = int(input())
def star(l):
if l == 3:
return ['***','* *','***']
arr = star(l//3)
stars = []
for i in arr:
stars.append(i*3)
for i in arr:
stars.append(i+' '*(l//3)+i)
for i in arr:
stars.append(i*3)
return stars
print('\n'.join(star(n)))