Невозможно создать желаемую комбинацию 2 и комбинацию 5
Текущий выход
Combination 1: Rutgers (93), Baylor (93), Orlando (96), Dublin (96), Spokane (96)
Combination 2: Rutgers (89), Baylor (90), Orlando (90), Dublin (85), Spokane (85)
Ожидаемый результат Примерно так.
COMBINATION 2: Trenton (89), Alabama (93), Orlando (96), Atlanta (96), Chicago (90)
COMBINATION 3: Rutgers (89), Baylor (93), Miami (96), Atlanta (85), SFO (90)
COMBINATION 4: Alabama (89), Trenton (93), Dublin (96), Chicago (96), Seattle (90)
COMBINATION 5: Baylor (89), Rutgers (93), SFO (96), Seattle (96), Trenton (90)
COMBINATION 6: Orlando (89), Atlanta (93), Spokane (96), Trenton (96), Alabama (85)
.
.
.
.
Это условия, которые мы добавили, чтобы код оправдал мои ожидания.
-У команды должны быть разные точки в соответствии с point_constraints,
Пример
COMBINATION 2: Trenton (89), Alabama (93), Orlando (96), Atlanta (96), Chicago (90)
COMBINATION 3: Rutgers (89), Baylor (93), Miami (96), Atlanta (85), SFO (90)
-Выберите только 1 команду из каждого набора
-5 комбинаций команд
from itertools import combinations, product
import random
# Define the teams and scores for each set
sets = {
"set_A": {
"Trenton": ["93", "96", "89", "90", "85"],
"Rutgers": ["93", "96", "89", "90", "85"],
},
"set_B": {
"Alabama": ["93", "96", "89", "90", "85"],
"Baylor": ["93", "96", "89", "90", "85"],
},
"set_C": {
"Orlando": ["93", "96", "89", "90", "85"],
"Miami": ["93", "96", "89", "90", "85"],
},
"set_D": {
"Atlanta": ["93", "96", "89", "90", "85"],
"Dublin": ["93", "96", "89", "90", "85"],
},
"set_E": {
"Chicago": ["93", "96", "89", "90", "85"],
"SFO": ["93", "96", "89", "90", "85"],
},
"set_J": {
"Seattle": ["93", "96", "89", "90", "85"],
"Spokane": ["93", "96", "89", "90", "85"],
}
}
# Define the score constraints (min, max) allowed for each score
score_constraints = {
"89": (0, 1),
"93": (0, 1),
"96": (0, 2),
"85": (0, 1),
"90": (0, 1),
}
# Function to count score occurrences in a combination
def count_score_occurrences(selected_scores, score_constraints):
score_counts = {score: 0 for score in score_constraints}
for score in selected_scores:
if score in score_counts:
score_counts[score] += 1
return score_counts
# Function to validate if a combination meets the score constraints
def is_valid_combination(score_counts, score_constraints):
return all(min_count
Подробнее здесь: https://stackoverflow.com/questions/790 ... ing-python
Невозможно сгенерировать комбинацию x и комбинацию y с помощью Python ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение