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 6956381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:51:43+00:00 2026-05-27T14:51:43+00:00

Say my list is {1,2,3,4} My title may not be descriptive enough but here

  • 0

Say my list is
{1,2,3,4}

My title may not be descriptive enough but here is what i want to do..
I want my code to generate the following

{ (1,2) , (3,4) }

{ (1,3) , (2,4) }

{ (1,4) , (2,3) }

{ (2,1) , (4,3) }

{ (3,1) , (4,2) }

{ (4,1) , (3,2) }

i.e i want all the 4C2 combinations of the set.

Note: here the initial four elements is just an illustrative number.. the number may vary uptill 8 or 10.

Now, how do i write the code for it (in C or php).

Basically, i want to know the algorithm. not the whole of it., even a headstart will be good enough..
I just cant think of anything to start from.
Kindly help.
Thanks.

I guess i did not explain it well; actually i did not get the problem myself.
what i want is that, say i have 4 teams and i want to play every team against the other then how do i generate all the fixtures.
in my example above; considering 1,2,3,4 as 4 teams. and
{(1,2), (3,4)} as a set of fixtures and so on.
how do i do this.
hence what i need is to generate all the NC2/ (N/2) set of fixtures. (N=4 in this case)

  • 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-05-27T14:51:44+00:00Added an answer on May 27, 2026 at 2:51 pm

    Basically, i want to know the algorithm. not the whole of it., even a
    headstart will be good enough.. I just cant think of anything to start
    from.

    If you want a headstart, the Python docs show the algorithm used for its implementation of a combinations function. Replace the range() with a plain for-loop and the yield with a printf and it should be easy to translate into C or PHP: http://docs.python.org/library/itertools.html#itertools.combinations

    Note the combinations of four things taken two at a time yields: (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4). Your sample output also includes the complement of each (i.e. (1, 2) is accompanied by (3, 4)).

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

Sidebar

Related Questions

My title may make my question sound confusing, but it is not. I have
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>
Sorry for vague question title. I've got a table containing huge list of, say,
I have a list of say 100k floats and I want to convert it
The title may sound simple and dumb, but allow me to explain. I am
First of all, the title of this question is horrible, but I didn't find
Let's say I have a list of books I want to render in a
Let's say I have the following lists: assignment = ['Title', 'Project1', 'Project2', 'Project3'] grades
Let's say I have the following class Book class Book{ String author; String title;
Maybe my title can be misleading, but let me clarify my question: Here's a

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.