흔히들 아는 그 숫자야구다.
310을 맞춰야 한다면, 012는 1 스트라이크 1볼이 된다.
그러니까 2는 아예 맞추지 못한 경우이므로 제외 시켜가면서 답의 가능성이 있는 수의 개수를 찾으면 된다.
숫자는 1 ~ 9 까지의 조합으로 3자리가 나올것이다.
1 ~ 9 까지의 모든 조합의 수인 permutations를 사용한다.
해당 조합에서 맞춰야 할 값이 482 라면, 4, 8, 2를 제외한 나머지 수들을 지워가면 된다.
data = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
all_comb = list(permutations(data, 3)) # 모든 경우의 수
n = int(input())
for _ in range(n):
num, s, b = map(int, sys.stdin.readline().split())
num = list(str(num)) # for문 돌리기 위한 형변환
remove_count = 0
for i in range(len(all_comb)):
i -= remove_count
strike = ball = 0
for j in range(3):
if all_comb[i][j] == num[j]: # 일치하면 스트라이크
strike += 1
elif num[j] in all_comb[i]: # 안에 있기만 하면 볼
ball += 1
if (strike != s) or (ball != b):
all_comb.remove(all_comb[i])
remove_count += 1
print(len(all_comb))