Indentati: unexpected indent라는 에러가 계속 뜨네요
넣은 코드는
import itertools
def generate_pairs(teams):
return list(itertools.combinations(teams, 2))
def minimum_days_required(num_teams=14, group_size=6):
# Generate all possible team combinations
all_combinations = list(itertools.combinations(range(num_teams), group_size))
# Track all pairs that need to be covered
all_pairs = set(itertools.combinations(range(num_teams), 2))
# Track the pairs that have been covered
covered_pairs = set()
days = 0
while covered_pairs != all_pairs:
best_combination = None
best_new_pairs = set()
for combination in all_combinations:
pairs_in_combination = set(itertools.combinations(combination, 2))
new_pairs = pairs_in_combination - covered_pairs
if len(new_pairs) > len(best_new_pairs):
best_combination = combination
best_new_pairs = new_pairs
covered_pairs.update(best_new_pairs)
days += 1
# Remove the used combination from the list
all_combinations.remove(best_combination)
print(best_combination)
return days
if __name__ == "__main__":
# Calculate the minimum number of days required
min_days = minimum_days_required(13, 5)
print(min_days)
제가 원하는 건 14개의 원소가 있는 집합에서 모든 원소들끼리 서로 1대1로 비교하는데(수작업으로 91번 해야 하겠지요)
한번에 최대 6개의 부분집합을 만들어 부분집합을 만들면 프로그램이 부분집합 내 모든 경우의 수를 비교해주는 상황에서
최소한의 횟수의 프로그램 구동으로 이 비교시행을 마치려면 몇번의 시행이 필요하며 그 집합의 목록은 어떻게 되는가?
사람 손으로 푸는 풀이도 들었는데 너무 노가다라...... 코드좀 봐주실 수 있나요
파이썬 Indentati: unexpected indent 에러는 들여쓰기문제가 많음 ㅇㅇ
어캐 해결하면 될까요