From ed0a2fed86e2393ad8496a8706fdbcd2ddb4f276 Mon Sep 17 00:00:00 2001
From: th-kim0823
Date: Sat, 25 Apr 2026 19:26:23 +0900
Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B9=80=EC=98=81=EA=B4=80=20=E2=86=94?=
=?UTF-8?q?=20=EC=9D=B4=EC=A4=80=EC=84=9D=20=EC=88=98=EB=8F=99=20swap=20(M?=
=?UTF-8?q?ANUAL=5FSWAPS=20=EB=A9=94=EC=BB=A4=EB=8B=88=EC=A6=98=20?=
=?UTF-8?q?=EC=B6=94=EA=B0=80)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Claude Opus 4.7 (1M context)
---
assign_teams.py | 32 +++++++++++++++++++++++++++++++-
participants.json | 4 ++--
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/assign_teams.py b/assign_teams.py
index 262d519..4694a5f 100644
--- a/assign_teams.py
+++ b/assign_teams.py
@@ -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회 시도에도 모든 제약 만족 실패")
diff --git a/participants.json b/participants.json
index 660e4f2..25324df 100644
--- a/participants.json
+++ b/participants.json
@@ -1,7 +1,7 @@
{
"김호승": "팀1",
"유준희": "팀1",
- "김영관": "팀1",
+ "이준석": "팀1",
"장다현": "팀1",
"강승형": "팀1",
"서한배": "팀2",
@@ -11,7 +11,7 @@
"박재호": "팀2",
"이성재": "팀3",
"이재광": "팀3",
- "이준석": "팀3",
+ "김영관": "팀3",
"정채윤": "팀3",
"변수민": "팀3",
"심성환": "팀4",