Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Round-Robin Tournament Matches

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Round-Robin Tournament Matches. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

ST Engineering Aerospace is validating a tournament scheduler for a competition involving aircraft maintenance teams. In a single round-robin tournament, every team plays every other team exactly once. Given the number of teams, calculate the total number of matches without simulating the schedule.

Formal Specification

Implement count_matches(team_count):

  • Input: team_count, a positive integer representing the number of teams.
  • Output: An integer equal to the number of unique matches in the tournament.
  • A match between teams A and B is the same as a match between teams B and A, so count each pair once.

Constraints

  • 1 <= team_count <= 10^9
  • team_count is an integer
  • Each pair of teams plays exactly once
  • Do not generate individual matches

Function Signature

def count_matches(team_count):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output