File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed
Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+
3+ input = sys .stdin .readline
4+
5+ n = int (input ())
6+
7+ stars = [[' ' for _ in range (n * 4 - 3 )] for _ in range (n * 4 - 3 )]
8+
9+
10+ def fill_star (num , x , y ):
11+ if num == 1 :
12+ stars [x ][y ] = '*'
13+ return
14+
15+ length = num * 4 - 3
16+ for i in range (length ):
17+ stars [y ][x + i ] = '*' # 처음 가로
18+ stars [y + i ][x ] = '*' # 처음 세로
19+ stars [y + length - 1 ][x + i ] = '*' # 마지막 가로
20+ stars [y + i ][x + length - 1 ] = '*' # 마지막 세로
21+
22+ fill_star (num - 1 , x + 2 , y + 2 )
23+
24+
25+ fill_star (n , 0 , 0 )
26+ for star in stars :
27+ print ('' .join (star ))
Original file line number Diff line number Diff line change 1+ import sys
2+
3+ input = sys .stdin .readline
4+
5+
6+ def cantor_set (arr , start , end ): # (놓친 부분) 파라미터로 start, end 두는 것
7+ length = end - start
8+ idx = length // 3 # 중심 인덱스
9+ if length == 1 :
10+ return
11+
12+ for i in range (idx , idx * 2 ):
13+ arr [start + i ] = ' '
14+
15+ cantor_set (arr , start , start + idx ) # 남은 왼쪽
16+ cantor_set (arr , start + idx * 2 , end ) # 남은 오른쪽
17+
18+
19+ while True :
20+ try :
21+ n = int (input ())
22+ arr = ['-' for _ in range (3 ** n )]
23+
24+ cantor_set (arr , 0 , len (arr ))
25+ print ('' .join (arr ))
26+ except :
27+ break
28+
29+ """
30+ 0
31+ 1
32+ 3
33+ 2
34+ """
Original file line number Diff line number Diff line change 1+ def solution (n , left , right ):
2+ answer = []
3+
4+ for i in range (left , right + 1 ):
5+ x = i // n # 행 (이거 어떻게 규칙 찾는거야..)
6+ y = i % n # 열
7+ answer .append (max (x + 1 , y + 1 ))
8+
9+ return answer
You can’t perform that action at this time.
0 commit comments