프로그래밍/기타
[카카오][Python3] 단체사진 찍기
snoopybox
2018. 8. 1. 21:11
2017년 카카오 코드 페스티벌 본선 1번 문제를 풀어보았다. 그냥 무식한 대입법으로...
참고 : http://tech.kakao.com/2017/09/14/code-festival-round-2/
입력은 위 문제와 조금 다르게 한줄씩 들어오는거 기준임.
예제 입력 :
2
N~F=0
R~T>2
#!/usr/bin/env python3 from itertools import permutations friends = ['A', 'C', 'F', 'J', 'M', 'N', 'R', 'T'] count = 0 conditions = [] for _ in range(int(input())): conditions.append(input()) for case in permutations(friends): for cond in conditions: others = abs(case.index(cond[0]) - case.index(cond[2])) - 1 if cond[3] == '=' and others != int(cond[4]): break elif cond[3] == '>' and others <= int(cond[4]): break elif cond[3] == '<' and others >= int(cond[4]): break else: count += 1 print(count)