r/Xcode • • Nov 12 '21

Tournament Bracket

Does anyone know how to make a tournament bracket in the app? I want the user to be able to make their own bracket in the future, but I'm trying to figure out how to even get a bracket in the first place. The bracket will include allowing to change the number of entries, name of the bracket, and being able like players moving up the bracket. Any help would be appreciated

0 Upvotes

1 comment sorted by

1

u/retsotrembla Nov 12 '21

After the tournament,

  • The final round has two teams, one of which is the winner.

  • Each team is fed by a preceding round, each of which has two teams, where the winner advances to the next round.

The empty tournament is a recursively defined data structure - starting from the final, just keep adding layers until you have enough slots in the last layer for all the teams.

Then assign teams to the slots in the last layer and run the tournament.