Random Team
generator.
Random teams feel fair when sizes are even and anyone can rerun the same draw.
Team sizes 4, 3, 3. Tap or drag a name to move it to another team.
- People
- 10
- Sizes
- 3 to 4 per team
10 people in 3 teams: 2,100 possible splits, and any two people share a team 26.7% of the time.
Keep people apart
Balance by rating
Several rounds, new partners
- Repeated pairs across these rounds
- 2
Who is with whom
| Names | ||
|---|---|---|
| 1 | 1 | Hal, Cruz, Jon, Gus |
| 1 | 2 | Ida, Ben, Eli |
| 1 | 3 | Dee, Fay, Ana |
| 2 | 1 | Ben, Fay, Cruz, Hal |
| 2 | 2 | Jon, Ana, Eli |
| 2 | 3 | Ida, Gus, Dee |
| 3 | 1 | Hal, Cruz, Dee, Eli |
| 3 | 2 | Ida, Jon, Fay |
| 3 | 3 | Gus, Ben, Ana |
Each round tries many shuffles and keeps the one with the fewest repeats. That does not promise the smallest total possible, and these rounds ignore ratings, the keep-apart list and any move by hand.
Ana and Ben shared a team in round 3.
This group at other team counts
| Teams | Sizes | Same-team chance | Possible splits |
|---|---|---|---|
| 2 | 5, 5126 splits | 44.4% | 126 |
| 3 (yours) | 4, 3, 32,100 splits | 26.7% | 2,100 |
| 4 | 3, 3, 2, 26,300 splits | 17.8% | 6,300 |
| 5 | 2, 2, 2, 2, 2945 splits | 11.1% | 945 |
| 6 | 2, 2, 2, 2, 1, 14,725 splits | 8.9% | 4,725 |
| 7 | 2, 2, 2, 1, 1, 1, 13,150 splits | 6.7% | 3,150 |
| 8 | 2, 2, 1, 1, 1, 1, 1, 1630 splits | 4.4% | 630 |
Sizes differ by at most one, because the names are dealt out in turn. The first teams get any extra people.
How it's worked out
The names are shuffled with the Fisher-Yates method, which walks back through the list and swaps each name with a random one at or before its place. Then they are dealt out one at a time like cards, so team sizes never differ by more than one. The first teams get any extra people.
If you ask for a team size, the number of teams comes from rounding up. That means a smaller team can appear, and even a team of one.
To join leftovers to other teams instead, the option for no short team rounds down. Nobody ends up below the size you asked for, and a few people end up in a team that is one larger.
Here n is everyone in the draw and each s is a team size. The top counts the ordered pairs inside teams and the bottom counts all ordered pairs. It answers the classic complaint that the same two people always end up together.
The shuffle number is a seed, the starting value for the random sequence. The same list and the same number always give the same teams, so anyone can rerun the draw and check it. A share link holds the settings and the number. Names stay out of it unless you choose to add them, since they may be pupils' names, and the person opening it needs the list to see the same teams.
Worked examples
Mr. Ortiz splits ten students into three teams
With shuffle number 5, the draw gives team 1: Fay, Ida, Eli, Gus; team 2: Dee, Cruz, Ben; team 3: Hal, Ana, Jon. The sizes are 4, 3, 3, the closest ten people can get to three even teams.
There are 2,100 different ways to split ten people into groups of those sizes. Any two named students have a 26.7% chance of sharing a team, so seeing a pair together now and then is expected.
Ben and Cruz should not work together this week. With that pair on the keep-apart list, the first draw from number 5 that separates them is number 6, which gives team 1: Hal, Eli, Ben, Fay; team 2: Gus, Ida, Jon; team 3: Cruz, Dee, Ana.
Eleven runners want to train in pairs
Eleven people do not divide into pairs. Asking for teams of two gives 6 teams with sizes 2, 2, 2, 2, 2, 1, so one runner, Jo, is alone.
With no short team, the same list gives 5 teams with sizes 3, 2, 2, 2, 2. The group of three is Finn, Jo, Ines. Which is better depends on the session: a lone runner can time the others, while a three is better when nobody should be left out.
Ms. Lane rotates groups over a term
Ms. Lane has twelve students in four groups of three and wants new partners each round. Each student meets 2 new people a round and there are only 11 to meet, so 5 rounds is the most that could ever be free of repeats.
| Round | Group | Students |
|---|---|---|
| 1 | 1 | Hana, Cal, Kit |
| 1 | 2 | Ike, Ada, Lou |
| 1 | 3 | Bea, Dot, Flo |
| 1 | 4 | Eve, Joy, Gil |
| 2 | 1 | Ada, Cal, Bea |
| 2 | 2 | Lou, Flo, Eve |
| 2 | 3 | Hana, Dot, Joy |
| 2 | 4 | Gil, Ike, Kit |
| 3 | 1 | Cal, Lou, Joy |
| 3 | 2 | Ike, Eve, Dot |
| 3 | 3 | Flo, Ada, Kit |
| 3 | 4 | Bea, Hana, Gil |
Three rounds came out with no repeated pairs. Pushed to 8 rounds, the same method counts 30 repeats, so she can plan on some pairs meeting again later in the term. Each round tries many shuffles and keeps the one with the fewest repeats, which does not promise the smallest total possible.
Reading your result
| Sizes | Possible splits | Chance a given pair shares a team |
|---|---|---|
| 5, 5 | 126 | 44.4% |
| 4, 3, 3 | 2,100 | 26.7% |
| 2, 2, 2, 2, 2 | 945 | 11.1% |
| 4, 4, 4, 4, 4 | 2,546,168,625 | 15.8% |
Smaller teams mean fewer repeat pairings. The list stays on this device between visits, so a class roster is ready next time. In two teams of five, a given pair lands together 44.4% of the time. In five pairs, it falls to 11.1%.
The limit on rounds is an upper limit. Six people in teams of three give 2 by the formula, but a second round always repeats a pair: any new team of three must hold two people who were together before. The exact version of this puzzle has a name, the social golfer problem, and CSPLib still lists the best schedule for 32 golfers as unknown.
Balanced teams trade some chance for fairness. With ratings, players are ranked and dealt in snake order, so the team that picks last in one lap picks first in the next. Ten players rated from 1 to 5 here come out as Lee, Ray, Uma, Xia, Wes (total 16) and Mo, Sam, Vic, Tess, Yan (total 16). Only ties are random, so expect the same strong players to be apart every time.
A draw is not a lottery. The generator's state is 32 bits, so it has 4,294,967,296 possible starting points. Twelve names have 479,001,600 orderings, which fits. Thirteen have 6,227,020,800, so some orders can never come up, as the Python documentation warns for most generators. That is fine for classrooms and pickup games.
Common mistakes
- Redrawing until it looks right, then calling it random. Picking one draw from several by eye is a choice and not chance. Use the keep-apart list for a real rule, and state it, so the rest of the draw stays fair.
- Entering a name twice by accident. Two lines that say Ana count as two people, and they can land on different teams. Check the count of people against your roster before you draw.
- Using this for a raffle with money or prizes at stake. The seeded generator is not meant for that, and the Python documentation warns that this kind of generator is unsuitable for security use. A regulated draw has its own rules, so check them where you live.
- Expecting a late arrival to change just one team. A new name changes the whole shuffle, so many people can move. If teams are already set, add the person to the smallest team by hand.
- Choosing roles before the draw. If a group needs a note-taker or a presenter, assign that after the teams are set, so the mix stays random.
- Treating a rating as a fact. A snake draft balances the totals you typed. If your ratings are guesses, the teams are only as fair as the guesses.