Pads the teams list to a power of two by adding BYEs to the end.
(teams: List[Team])
| 195 | |
| 196 | |
| 197 | def pad_teams_power_of_two(teams: List[Team]) -> List[Team]: |
| 198 | """ |
| 199 | Pads the teams list to a power of two by adding BYEs to the end. |
| 200 | """ |
| 201 | assert len(teams) > 0 |
| 202 | num_teams_orig = len(teams) |
| 203 | num_teams_goal = 2**math.ceil(math.log(num_teams_orig, 2)) |
| 204 | for ranking in range(len(teams) + 1, num_teams_goal + 1): |
| 205 | teams.append(None) |
| 206 | |
| 207 | logging.debug('Padded {} teams to {} teams (goal {})'.format( |
| 208 | num_teams_orig, len(teams), num_teams_goal)) |
| 209 | |
| 210 | assert len(teams) & (len(teams) - 1) == 0 |
| 211 | return teams |
| 212 | |
| 213 | |
| 214 | def queue_match(conn, round_num, index, red, blue, maps): |