728x90
320x100
구현
from itertools import permutations
N = int(input())
arr = [ list(input().split()) for _ in range(N)]
cnt = 0
# 3자리 무작위 수 뽑기 (순열)
for per in permutations(range(1, 10), 3):
ok = True
for num, st, bl in arr:
real_st = real_bl = 0
for i in range(3):
if str(per[i]) == num[i] :
real_st += 1
elif str(per[i]) in num:
real_bl += 1
if int(st) != real_st or int(bl) != real_bl:
ok = False
break
if ok :
cnt += 1
print(cnt)
- 부르트 포스 알고리즘 활용.
728x90
320x100
'💻 하나씩 차곡차곡 > 백준알고리즘 (Python,Java)' 카테고리의 다른 글
백준 1461번 파이썬 (0) | 2024.12.11 |
---|---|
백준 1026번 파이썬 (0) | 2024.12.10 |
백준 5585번 파이썬 (0) | 2024.12.06 |
백준 1182번 파이썬 (0) | 2024.11.14 |
백준 23246번 파이썬 (0) | 2024.10.15 |