Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8363375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:09:40+00:00 2026-06-09T12:09:40+00:00

i am trying to write a competition code that will get a list of

  • 0

i am trying to write a competition code that will get a list of competitors and then will randomly decide who they must face at each round, round-robin style without eliminations.
wiki article about this type of competition

at the end of each round the winner of each match will receive a point.

when all possible fights are finished, the one with the most points wins.

but i am having some trouble, here is my code so far:

import itertools

# list of competitors (does not need to be even, in this case, 7)
# maybe this should be a dict with their wins and loses like:
# {'Andy': [2,['Bob','Charlie'],0,[]], ... }
# which means andy won 2 times, against bob and charlie, and lost 0 times
competitors = ['Andy', 'Bob', 'Charlie', 'Daniel', 'Eric', 'Ferdinand', 'Gabriel']
# the starting round number
round_number = 1
# holds the winner
winner = None

# start the competition
print "The competitors are: \n" + " ".join(competitors)

# round handler
def do_round():
    #round notifier
    print "Round " + str(round_number)

    #here is the problem
    matches = itertools.permutations(competitors,2)
    for match in matches: 
        print match

    # increase round number
    round_number += 1
    #return this rounds matches
    return matches

# gets the winners of each round for each match 
def get_winners(matches):
    winners = []
    for match in matches:
        winners.append(raw_input("who won?: " + " or ".join(match)))         

# decides if the games are over yet
def is_there_a_winner(winners):
    # this function should know how to get every rounds winners and add their points
    # and then decide if the game is over and there is a total winner
    winner = ??


# main loop
while not winner:
    matches = do_round()
    get_winners(matches)
    is_there_a_winner(winners)

Edit: sorry the question was asked before i could write this part for some reason.

my problem is that the permutations gives ALL POSSIBLE permutations, i just want to get permutations of the competitors for a single round, and then next time i run it, to be able to reference who they have already fought against and not have that match come up again.

Edit2: i decided to add a “desired result” to my post.

i want the output to be something like this:

The competitors are: 
Andy Bob Charlie Daniel Eric Ferdinand Gabriel
Round 1
Andy     vs   Bob
Charlie  vs   Daniel
Eric     vs   Ferdinand
Gabriel sits out
Round 1 Results:
Andy     beat Bob
Charlie  beat Daniel
Eric     beat Ferdinand
Round 2
Andy     vs   Daniel
Bob      vs   Gabriel
Eric     vs   Charlie
Ferdinand sits out

... etc etc ... until at the end the winner (highest score) is revealed.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:09:41+00:00Added an answer on June 9, 2026 at 12:09 pm

    i found an answer here:

    https://stackoverflow.com/a/11246261/1561176

    this does what i needed, just need to input my own values now. and modify the way it does the output.

    probably should have tried looking deeper, thanks for the help here everyone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m trying write code that after reset set up rrpmax as 3000. It
Trying to write app for service technicians that will display open service calls within
Trying to write a couple of functions that will encrypt or decrypt a file
Trying to write a code at the moment that basically tests to see if
Trying to write a code that searches hash values for specific string's (input by
I'm trying to profile a C++ application, that I did not write, to get
I'm trying write a program that takes a list of names, sorts those names,
I am trying write a function that generates simulated data but if the simulated
Trying to write out syslog entries containing strings but they don't register. // person.name
I have the following C-code which I am trying to re-write in java. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.