# Calculating Swiss Record Required to Reach Elimination Rounds

Here’s some Python that calculates how many players will reach each record in a Swiss tournament with a Top 8 or similar cut.

```from typing import Sequence

# Math from https://www.mtgsalvation.com/forums/magic-fundamentals/magic-general/325775-making-the-cut-in-swiss-tournaments
def swisscalc(num_players: int, num_rounds: int, num_elimination_rounds: int) -> Sequence[int]:
num_players_in_elimination_rounds = 2 ** num_elimination_rounds
base = num_players / (2 ** num_rounds)
num_players_by_losses = [0] * (num_rounds + 1)
multiplier = 1.0
total_so_far = 0
record_required = None
for losses in range(0, num_rounds + 1):
wins = num_rounds - losses
numerator = wins + 1
denominator = losses
if denominator > 0:
multiplier *= (numerator / denominator)
num_players_by_losses[losses] = base * multiplier
if not record_required and num_players_in_elimination_rounds:
total_so_far += num_players_by_losses[losses]
return num_players_by_losses
```

Example usage:

```\$ python3
>>> rounds = 4
>>> r = swisscalc(24, rounds, 3)
>>> for losses in range(len(r)):
...     print(f'{r[losses]} players at {rounds - losses}–{losses}')
...
1.5 players at 4–0
6.0 players at 3–1
9.0 players at 2–2
6.0 players at 1–3
1.5 players at 0–4
```