You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Google Sheets/Excel中按排名分组选手至固定规模团队

在Google Sheets/Excel中实现赛事分组方案

核心分组规则确认

先明确分组的数学逻辑:设总选手数为N,需满足 4x + 3y = N(x为4人组数量,y为3人组数量),同时适配种子排名的均匀分配(避免高排名选手集中,方便后续轮次配对)。具体计算规则:

  • 若N % 3 = 1:设1个4人组,剩余人数拆分为3人组(如13人=4×1+3×3)
  • 若N % 3 = 2:设2个4人组,剩余人数拆分为3人组(如14人=4×2+3×2)
  • 若N % 3 = 0:优先按4人组拆分,若无法整除则减少1个4人组,补1个3人组(如12人=4×3;15人=4×3+3×1)

无公式/宏实现方式(手动快速分配)

如果选手数量不多,可基于种子排名蛇形手动分组:

  1. 按种子排名从高到低列好选手名单
  2. 先列出所有分组编号(如1组、2组...)
  3. 第1轮:按1→2→3→...的顺序给前N个选手分配组号
  4. 第2轮:按...→3→2→1的逆序分配剩余选手
    这种方式能保证高排名选手均匀分散到各组,适配后续轮次配对逻辑。

公式自动实现(适用于Google Sheets/Excel)

假设选手种子排名在B列(B1为表头),姓名在C列,在D2单元格输入以下公式,向下拖拽即可自动生成分组:

=LET(
    total_players, COUNTA(C:C)-1,
    group4, IF(MOD(total_players,3)=1,1,IF(MOD(total_players,3)=2,2,IF(MOD(total_players,4)=0,total_players/4,(total_players-3)/4))),
    group3, (total_players-4*group4)/3,
    total_groups, group4+group3,
    player_seq, ROW()-2,
    cycle, CEILING((player_seq+1)/total_groups,1),
    group_pos, IF(MOD(cycle,2)=1,MOD(player_seq,total_groups)+1,total_groups-MOD(player_seq,total_groups)),
    group_pos&"组"
)

公式说明:

  • total_players:自动统计总选手数(排除表头)
  • group4/group3:自动计算4人组、3人组数量
  • group_pos:通过蛇形逻辑计算当前选手的分组编号,保证高排名均匀分布

脚本宏实现(更灵活,适配复杂逻辑)

如果你熟悉循环逻辑,用VBA(Excel)或Google Apps Script(Google Sheets)能更灵活调整规则:

Excel VBA示例

Sub AssignTournamentGroups()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Dim totalPlayers As Integer
    totalPlayers = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row - 1 'C列存选手姓名,第1行是表头
    
    '计算分组数量
    Dim group4 As Integer, group3 As Integer, totalGroups As Integer
    If totalPlayers Mod 3 = 1 Then
        group4 = 1
    ElseIf totalPlayers Mod 3 = 2 Then
        group4 = 2
    Else
        group4 = IIf(totalPlayers Mod 4 = 0, totalPlayers / 4, (totalPlayers - 3) / 4)
    End If
    group3 = (totalPlayers - 4 * group4) / 3
    totalGroups = group4 + group3
    
    '蛇形分配分组
    Dim playerIdx As Integer, groupIdx As Integer, direction As Integer
    direction = 1 '1=正序,-1=逆序
    groupIdx = 1
    
    For playerIdx = 2 To totalPlayers + 1
        ws.Cells(playerIdx, "D").Value = groupIdx & "组" 'D列输出分组
        
        '更新分组索引,蛇形切换方向
        If direction = 1 Then
            groupIdx = groupIdx + 1
            If groupIdx > totalGroups Then
                groupIdx = totalGroups - 1
                direction = -1
            End If
        Else
            groupIdx = groupIdx - 1
            If groupIdx < 1 Then
                groupIdx = 2
                direction = 1
            End If
        End If
    Next playerIdx
End Sub

Google Apps Script示例

function assignTournamentGroups() {
    const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    const lastRow = sheet.getLastRow();
    const totalPlayers = lastRow - 1; //第1行是表头
    
    //计算分组数量
    let group4, group3, totalGroups;
    if (totalPlayers % 3 === 1) {
        group4 = 1;
    } else if (totalPlayers % 3 === 2) {
        group4 = 2;
    } else {
        group4 = totalPlayers % 4 === 0 ? totalPlayers / 4 : (totalPlayers - 3) / 4;
    }
    group3 = (totalPlayers - 4 * group4) / 3;
    totalGroups = group4 + group3;
    
    //蛇形生成分组数据
    let groupIdx = 1;
    let direction = 1;
    const groupAssignments = [];
    for (let i = 0; i < totalPlayers; i++) {
        groupAssignments.push([groupIdx + "组"]);
        
        //切换分配方向
        if (direction === 1) {
            groupIdx++;
            if (groupIdx > totalGroups) {
                groupIdx = totalGroups - 1;
                direction = -1;
            }
        } else {
            groupIdx--;
            if (groupIdx < 1) {
                groupIdx = 2;
                direction = 1;
            }
        }
    }
    
    //写入到D列
    sheet.getRange(2, 4, totalPlayers, 1).setValues(groupAssignments);
}

扩展与验证

  • 验证:输入12、13、14、15等测试人数,检查分组数量和选手分配是否符合预期
  • 扩展:若后续轮次需要调整分组逻辑(如按组内排名重新分组),只需修改蛇形分配的方向规则,或调整分组数量的计算逻辑即可

内容的提问来源于stack exchange,提问作者Magos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 08:06:16