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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:32:39+00:00 2026-06-14T21:32:39+00:00

I have an array with different numbers (integers). The length of that array is

  • 0

I have an array with different numbers (integers). The length of that array is not set, so it is different every time I run my program. Then I have two other arrays and I want the program to evaluate all possibilites for the distribution of the first array into the other two arrays. For example:

Array 1: 1,3,5

Now the programm should make the other two arrays for example like this:

Array 2: 1,3
Array 3: 5

Or like this:

Array 2: 1,5
Array 3: 3
  • 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-14T21:32:41+00:00Added an answer on June 14, 2026 at 9:32 pm

    Consider the placement of an item as a binary digit, then you see that all binary number with the same number of digits as the number of items represent all possible combinations.

    So, for three items you have 8 possible combinations:

    000: [1,3,5], []
    001: [3,5], [1]
    010: [1,5], [3]
    011: [5], [1,3]
    100: [1,3], [1]
    101: [3], [1,5]
    110: [1], [3,5]
    111: [], [1,3,5]
    

    You can calculate the number of possible combinations using 1 << theArray.Length.

    You can get a specific combination (0 to possible-1) using:

    public static void GetArrays(int[] arr, int combination, out int[] arr1, out int[] arr2) {
      List<int> a = new List<int>();
      List<int> b = new List<int>();
      foreach (int value in arr) {
        if ((combination & 1) == 1) {
          b.add(value);
        } else {
          a.add(value);
        }
        combination >>= 1;
      }
      arr1 = a.ToArray();
      arr2 = b.ToArray();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a struct-array that contains details of different reports that can be run.
I have an array of different times that looks like this: 20120628061533.0, 20120628064851.0, 20120628064853.0,
I have two different arrays. One array, a, for a list of people. My
I'm trying to come up with a way combine two arrays that have different
I have an array of random length full of random integers. For the sake
I have two set of integers(i.e. first one is: 2,3,4,5 and second one is
I have an array of integers, which could run into the hundreds of thousands
I have a string array of 3 different command line commands. Instead of writing
I have a 4D array of measurements in MATLAB. Each dimension represents a different
How can I store arrays in single array? e.g. I have four different arrays,

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.