from itertools import permutations
import re


def regex_pattern(input_string):
    return re.compile(input_string.replace("*", ".{1}"))
    

def solution(user_id, banned_id):
    answer = []
    count = 0
    
    banned_id = list(map(regex_pattern, banned_id))
    
    for case in permutations(user_id, len(banned_id)):
        for c, b in zip(case, banned_id):
            if not b.fullmatch(c):
                break
                
        else:
            answer.append(tuple(sorted(case)))
    
    return len(set(answer))

+ Recent posts