Files
Algorithm/백준/Silver/2784. 가로 세로 퍼즐/가로 세로 퍼즐.py

22 lines
625 B
Python

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)