T-coding
백준 2784 가로 세로 퍼즐 / Python 본문
728x90
728x90
https://www.acmicpc.net/problem/2784
2784번: 가로 세로 퍼즐
6개 단어를 3*3 가로 세로 퍼즐에 놓을 수 없다면 0을 출력한다. 그렇지 않다면, 3개 줄에 퍼즐을 출력한다. 만약 가능한 답이 여러개라면 사전순으로 앞서는 것을 출력한다. 사전순으로 비교를 할
www.acmicpc.net

코드
더보기
arr = [input() for _ in range(6)]
arr.sort()
ans_list = []
for i in range(6):
for j in range(6):
for k in range(6):
if i == j or i == k or j == k:
continue
temp = [arr[i], arr[j], arr[k]]
temp2 = temp.copy()
for h in range(3):
temp2.append(temp[0][h] + temp[1][h] + temp[2][h])
temp2.sort()
if arr == temp2:
ans_list.append(temp[0] + temp[1] + temp[2])
ans_list.sort()
if len(ans_list):
for i in range(0, 10, 3):
print(ans_list[0][i:i + 3])
else:
print(0)
728x90
300x250
'Baekjoon' 카테고리의 다른 글
백준 14467 소가 길을 건너간 이유 1 (0) | 2023.03.19 |
---|---|
백준 3024 마라톤 틱택토 / Python (0) | 2023.03.19 |
백준 1913 달팽이 / Python (0) | 2023.03.18 |
백준 1074 Z / Python (0) | 2023.03.18 |
백준 1029 그림 교환 / Python (0) | 2023.03.18 |