코드
다른 사람의 풀이
from collections import deque
from itertools import combinations
def solution(relation):
n_row = len(relation)
n_col = len(relation[0])
candidates=[]
for i in range(1,n_col+1):
candidates.extend(combinations(range(n_col),i))
final=[]
for keys in candidates:
tmp=[tuple([item[key] for key in keys]) for item in relation]
if len(set(tmp))==n_row:
final.append(keys)
answer=set(final[:])
for i in range(len(final)):
for j in range(i+1,len(final)):
if len(final[i])==len(set(final[i]).intersection(set(final[j]))):
answer.discard(final[j])
return len(answer)