1. Problem
2. My Solution
import sys
def starmake(n,x,y): # 종료 조건 (최소 출력)
if n == 3:
for i in range(3):
for j in range(3):
if (i == 1 and j == 1) == False:
arr[x+i][y+j] = "*"
else: # 재귀 함수 설정
for i in range(0,n,n//3):
for j in range(0,n,n//3):
if (i == n//3 and j == n//3) == False:
starmake(n//3,x+i,y+j)
n = int(sys.stdin.readline().strip())
arr = [[" "]* n for _ in range(n)]
starmake(n,0,0)
for i in range(n):
print(''.join(arr[i]))
3. Others' Solutions
def sta(n):
if n == 1:
return ['*']
sta1 = sta(n//3)
res = []
for i in sta1:
res.append(i * 3)
for i in sta1:
res.append(i + ' '*(n//3) + i)
for i in sta1:
res.append(i * 3)
return res
a = int(input())
print('\n'.join(sta(a)))
4. Learned
1. Problem
2. My Solution
import sys
def hinoi(n,start,assist,dest):
global count
if n == 1:
result.append(str(start)+" "+str(dest))
count+=1
else:
hinoi(n-1,start,dest,assist)
hinoi(1,start,assist,dest)
hinoi(n-1,assist,start,dest)
n = int(sys.stdin.readline().strip())
count = 0
result = []
hinoi(n,1,2,3)
print(count)
for i in result:
print(i)
3. Learned
1. Problem
2. My Solution
import sys
import itertools
n,m = map(int,sys.stdin.readline().strip().split())
card_list = list(map(int,sys.stdin.readline().strip().split()))
result = list(itertools.combinations((card_list),3))
result = [m - sum(result[i]) for i in range(len(result))]
result = sorted(filter(lambda x: x >=0 , result))
print(m-min(result))
3. Others' Solutions
import sys
input = sys.stdin.read
def sol2798():
n, m, *cards = map(int, input().split())
answer = 0
for i in range(n-2):
for j in range(i+1, n-1):
for k in range(j+1, n):
s = cards[i]+cards[j]+cards[k]
if answer<s<=m:
answer = s
print(answer)
4. Learned