# 숫자 야구 - 프로그래머스
from itertools import permutations
def solution(baseball):
ret = 0
li = list(permutations([1, 2, 3, 4, 5, 6, 7, 8, 9], 3))
for ele in li:
x, y, z = map(str, ele)
for idx, (num, s, b) in enumerate(baseball):
c_s, c_b = 0 , 0
cx, cy, cz = map(str, str(num))
if cx == x: c_s += 1
if cy == y: c_s += 1
if cz == z: c_s += 1
if c_s != s: break
if cy == x or cz == x: c_b += 1
if cx == y or cz == y: c_b += 1
if cx == z or cy == z: c_b += 1
if c_b != b: break
if idx + 1 == len(baseball):
ret += 1
return ret