REPOSITORY CODING · HARD
Backtrack without forgetting drawn opponents
The first dead-end pairing aborts the search, and previous drawn opponents are considered unplayed. Restore exhaustive bounded matching and record every completed encounter in the no-rematch set.
Repository ImplementationSwiss tournament pairing desk
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
Ruby on Rails · 80 minute session
- Create a bounded Swiss-style next-round pairing from at most 12 registered players and validated completed history. Scores use doubled units: win two, draw one, loss zero and historical bye two. Optional initialPoints2 imports prior score credit. Upcoming pairings and the selected upcoming bye do not yet change standings.
- Standings sort by points2 descending, Buchholz2 descending, rating descending and lexical ID. Buchholz sums each encountered opponent final points2 after complete history; repeated historical encounters contribute once per game and byes add no opponent. Withdrawn players remain in historical standings but cannot be paired.
- For an odd active field, prefer a player without a previous bye; if all have had one, allow a repeat. Within the eligible set choose lowest points2, lowest rating then lexical ID. Historical players may appear only once per round, including byes.
- Pair every remaining active player exactly once without rematching any historical opponent. Search all bounded legal matchings and minimize total point gap, then rating gap, then color imbalance, then lexical unordered-pair signature. A failed first branch must not terminate alternatives.
- Do not assign a third consecutive identical color, including colors in drawn games. Among legal orientations minimize the resulting absolute color biases; ties give the higher-standing player white. Report no-legal-pairing if no complete matching and orientation exist. This explicit training policy is not a claim of full FIDE rule compliance.