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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:26:15+00:00 2026-06-14T23:26:15+00:00

I have N data elements (say, 1:N) that I want to distribute into two

  • 0

I have N data elements (say, 1:N) that I want to distribute into two distinct groups. I do not know what the best distribution is, so I want to test every possible pairing, but ignore symmetric results.

I need a function that has such a result:

>> pairings(1:2)
{
  [1], [2]
}

>> pairings(1:3)
{
  [1], [2,3]
  [2], [1,3]
  [3], [1,2]
}

>> pairings(1:4)
{
  [1], [2,3,4]
  [2], [1,3,4]
  [3], [1,2,4]
  [4], [1,2,3]
  [1,2], [3,4]
  [1,3], [2,4]
  [1,4], [2,3]
}

Of course an algorithm that employs a lot of looping would be easy enough to write, but I guess there is a solution that does feel more like matlab.

  • 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-14T23:26:16+00:00Added an answer on June 14, 2026 at 11:26 pm

    This is essentially a power set enumeration problem. Assume that the element 1 is in the first of the two sets. Enumerate the power set of the elements 2 .. N. This can be done by looping through the binary numbers from 1 .. 2^(N-1). Add the element 1 to the result set as the first set in the pair. Take the complement of the result set as your other set. Toss away the empty set as a subset if it’s not relevant for your problem.

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

Sidebar

Related Questions

How do i select elements that have my custom data attribute data-validate with jQuery
Let's say I have a database filled with people with the following data elements:
I have two arrays, say A and B with |A|=8 and |B|=4. I want
Say that I have an integer-indexed array of length 400, and I want to
I have several data that looks like this: Vector1_elements = T,C,A Vector2_elements = C,G,A
Possible Duplicate: jquery data selector I have several elements with class 'connection_name'. Each one
I have array of strings, String[] data and it's 10 elements has value P
I have some data in an XML element that looks like this: <?xml version=1.0
Say I have a Group data structure which contains a list of Element objects,
What is the best way to embed data in html elements for later use?

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.