I am in the process of developing a unique UEFA Champions League 24 'Swiss Model' tournament with 36 teams. Each team is set to compete against 8 different opponents, resulting in a total of 144 matches. I already have a list of matchups prepared. Is there a method to organize these matchups so that every team can have an equal number (in this case, 4) of home and away games? The first position in each matchup designates the home team, while the second position indicates the away team.
I've made an attempt to verify if the total number of home games for the first team exceeds 4 matches (given the 8 rounds). If it does, then it switches to playing as the away team. However, the results are still not evenly distributed.
const matchups = [
[
"35",
"36"
],
...
]
// JavaScript code continues here...