from itertools import combinations
def solution(relation):
answer = 0
# ls : [0,1] 과 같은 index 리스트
def unique(ls):
res = []
for re in relation:
k = ""
for i in ls:
k += re[i] + " "
res.append(k)
sres = set(res)
return len(res) == len(sres)
def check(k, ls):
for l in ls:
if len(set(l) - set(k)) == 0:
return False
return True
ls = []
for i in range(1, len(relation[0]) + 1):
for k in combinations([i for i in range(len(relation[0]))], i):
if unique(k) and check(k, ls) :
answer += 1
ls.append(k)
return answer
res = [tuple([item[key] for key in ls]) for item in relation]
이런 식으로 할 수도 있음
a.issubset(b)
b.issupperset(a)
나는 len(set(a) - set(b)) == 0
을 이용했다.