# 불량 사용자 - 프로그래머스
from itertools import permutations
def check(user, ban):
if len(user) != len(ban):
return False
else:
for i, j in zip(user, ban):
if j == '*':
continue
if i != j:
return False
return True
def solution(user_id, banned_id):
ret = []
for i in permutations(user_id, len(banned_id)):
cnt = 0
for x, y in zip(i, banned_id):
if check(x, y):
cnt += 1
if cnt == len(banned_id):
if set(i) not in ret:
ret.append(set(i))
return len(ret)