feat: 김영관 ↔ 이준석 수동 swap (MANUAL_SWAPS 메커니즘 추가)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
th-kim0823
2026-04-25 19:26:23 +09:00
parent 1db7ad397d
commit ed0a2fed86
2 changed files with 33 additions and 3 deletions

View File

@@ -63,6 +63,11 @@ NUM_TEAMS = 7
TEAM_SIZES = [5] * 6 + [4]
SEED = 20260428 # 행사일 시드 (재현 가능)
# 자동 배정 후 수동 swap (이름 쌍)
MANUAL_SWAPS = [
("김영관", "이준석"),
]
def assign_one(seed):
"""
@@ -154,13 +159,38 @@ def validate(teams):
return True, "OK"
def apply_swaps(teams, swaps):
"""이름 쌍을 받아 두 사람의 팀 위치를 교환."""
name_to_loc = {}
for ti, team in enumerate(teams):
for pi, (name, _) in enumerate(team):
name_to_loc[name] = (ti, pi)
for a, b in swaps:
if a not in name_to_loc or b not in name_to_loc:
raise ValueError(f"swap 대상 못 찾음: {a}, {b}")
ti_a, pi_a = name_to_loc[a]
ti_b, pi_b = name_to_loc[b]
if ti_a == ti_b:
continue # 같은 팀이면 의미 없음
teams[ti_a][pi_a], teams[ti_b][pi_b] = (
teams[ti_b][pi_b],
teams[ti_a][pi_a],
)
# 위치 갱신
name_to_loc[a] = (ti_b, pi_b)
name_to_loc[b] = (ti_a, pi_a)
return teams
def assign(base_seed):
"""시드 재시도로 모든 제약 만족하는 배정 찾기."""
"""시드 재시도로 모든 제약 만족하는 배정 찾기. 이후 수동 swap 적용."""
for offset in range(10000):
seed = base_seed + offset
teams = assign_one(seed)
ok, msg = validate(teams)
if ok:
teams = apply_swaps(teams, MANUAL_SWAPS)
return teams, seed, offset + 1
raise RuntimeError("10000회 시도에도 모든 제약 만족 실패")

View File

@@ -1,7 +1,7 @@
{
"김호승": "팀1",
"유준희": "팀1",
"김영관": "팀1",
"이준석": "팀1",
"장다현": "팀1",
"강승형": "팀1",
"서한배": "팀2",
@@ -11,7 +11,7 @@
"박재호": "팀2",
"이성재": "팀3",
"이재광": "팀3",
"이준석": "팀3",
"김영관": "팀3",
"정채윤": "팀3",
"변수민": "팀3",
"심성환": "팀4",