Files
hackerthon-vote/assign_teams.py
th-kim0823 ffce2b9bfc fix: EffTech 신규 합류 화합 위해 모든 팀에 EffTech 1명 이상 필수
기존 제약(같은 부서 ≤2명) 만으로는 EffTech 0명인 팀 발생 (재배정 전 팀2).
신규 부서 ≥1명 제약 추가로 모든 팀이 기존-신규 섞이도록 보장.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 19:05:20 +09:00

114 lines
3.4 KiB
Python

"""
참가자 35명 → 7팀 (팀당 5명) 배정.
같은 부서 2명 이하 제약. 랜덤 시드로 재현 가능.
결과: participants.json (이름→팀 매핑) + 콘솔 출력.
"""
import json
import random
from collections import Counter
from pathlib import Path
PEOPLE = [
("한지승", "MLOps Platform"),
("변수민", "MLOps Data"),
("박재호", "MLOps Data"),
("김태현", "MLOps Data"),
("강승형", "MLOps Data"),
("손현준", "MLOps Data"),
("김동국", "MLOps Data"),
("김재현", "MLOps HPC"),
("이준석", "MLOps HPC"),
("오근현", "MLOps HPC"),
("김정명", "MLOps HPC"),
("김영관", "MLOps HPC"),
("유용혁", "MLOps HPC"),
("최호진", "MLOps HPC"),
("전효준", "MLOps HPC"),
("김병훈", "MLOps System"),
("이지환", "MLOps System"),
("서희", "MLOps System"),
("정채윤", "MLOps System"),
("장혁진", "MLOps System"),
("장다현", "MLOps System"),
("박영훈", "MLOps System"),
("길주현", "MLOps System"),
("조민정", "AI Efficiency Tech"),
("김민섭", "AI Efficiency Tech"),
("김호승", "AI Efficiency Tech"),
("서한배", "AI Efficiency Tech"),
("심성환", "AI Efficiency Tech"),
("유준희", "AI Efficiency Tech"),
("이성재", "AI Efficiency Tech"),
("이재광", "AI Efficiency Tech"),
("이정태", "AI Efficiency Tech"),
("이준형", "AI Efficiency Tech"),
("정현준", "AI Efficiency Tech"),
("유지원", "AI Efficiency Tech"),
]
NUM_TEAMS = 7
TEAM_SIZE = 5
MAX_SAME_DEPT = 2
SEED = 20260428 # 행사일 시드 (재현 가능)
# EffTech 신규 합류 → 모든 팀에 ≥1명 필수 (화합 목표)
NEW_DEPT = "AI Efficiency Tech"
MIN_NEW_PER_TEAM = 1
def is_valid(teams):
for team in teams:
depts = [d for _, d in team]
# 같은 부서 ≤ 2명
if max(Counter(depts).values()) > MAX_SAME_DEPT:
return False
# 신규 부서 ≥ 1명
if depts.count(NEW_DEPT) < MIN_NEW_PER_TEAM:
return False
return True
def assign(seed):
rng = random.Random(seed)
for attempt in range(20000):
shuffled = PEOPLE[:]
rng.shuffle(shuffled)
teams = [
shuffled[i * TEAM_SIZE : (i + 1) * TEAM_SIZE]
for i in range(NUM_TEAMS)
]
if is_valid(teams):
return teams, attempt + 1
raise RuntimeError("제약 만족하는 배정 20000회 시도에도 실패")
def main():
assert len(PEOPLE) == NUM_TEAMS * TEAM_SIZE, (
f"인원수 불일치: {len(PEOPLE)}명, 기대 {NUM_TEAMS * TEAM_SIZE}"
)
teams, attempts = assign(SEED)
print(f"# 시드 {SEED}, 시도 {attempts}회 만에 배정 완료\n")
mapping = {}
for i, team in enumerate(teams, 1):
team_name = f"{i}"
dept_counts = Counter(d for _, d in team)
dept_summary = ", ".join(f"{d.replace('MLOps ', '').replace('AI Efficiency Tech', 'AI Eff')} {c}" for d, c in dept_counts.items())
print(f"## {team_name} ({dept_summary})")
for name, dept in team:
print(f" - {name} ({dept})")
mapping[name] = team_name
print()
out = Path(__file__).parent / "participants.json"
out.write_text(
json.dumps(mapping, ensure_ascii=False, indent=2),
encoding="utf-8",
)
print(f"저장: {out}")
if __name__ == "__main__":
main()