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

  • Home
  • SEARCH
  • 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 859813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:43:44+00:00 2026-05-15T08:43:44+00:00

I have an array from ten (or more) numbers, for example: arr[1,2,3,4,5,6,7,8,9,10] I want

  • 0

I have an array from ten (or more) numbers, for example:

arr[1,2,3,4,5,6,7,8,9,10]

I want a method to check if three numbers from this arrays have the same sum to another three numbers (I want to get all the possibilities!), for example:

{1.8.10}  {2.10.7}  {3.7.9}   {4.9.6}   {5.6.8}  {Sum of each set: 19}
{1.6.10}  {3.10.4}  {5.4.8}   {7.8.2}   {9.2.6}  {Sum of each set: 17}
{6.3.5}   {7.5.2}   {8.2.4}   {9.4.1}   {10.1.3} {Sum of each set: 14}

Update:

That’s another example to what exactly I want to do:

alt text http://img208.imageshack.us/img208/1131/77603708.png

  • 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-15T08:43:44+00:00Added an answer on May 15, 2026 at 8:43 am

    Create a map of sets. Setup a triple nested for loop and start adding numbers. Every sum becomes a key into the map. The set is the 3 numbers you used. Should only be a dozen or so lines of code.

    
    map&ltint,set&ltint> > sums;
    
    for(int i=0; i&ltARRAY_SIZE; i++)
    {
      for(int j=0; j&ltARRAY_SIZE; j++)
      {
        if(j &lt= i)
          continue;
    
        for(int k=0; k&ltARRAY_SIZE; k++)
        {
          if(k &lt= i || k &lt= j)
            continue;
    
          int localSum = arr[i] + arr[j] + arr[k];
          set&ltint> thisSum;
          thisSum.insert(arr[i]);
          thisSum.insert(arr[j]);
          thisSum.insert(arr[k]);
          sums.insert(make_pair(localSum, thisSum));
        }
      }
    }
    

    and just iterate through the sums map and display your sets as you want. I’m not 100% sure on my continue logic here, but I think it’s correct. The idea will work, though it’s at least cubic in complexity.

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

Sidebar

Related Questions

I have an array from this mysql query: SELECT COUNT(*) as opens, HOUR(FROM_UNIXTIME(open_date)) as
I have an array of values that is passed to my function from a
So I have an array of records retreived from a database. The array is
I have a byte array in memory, read from a file. I would like
I have been working with a string[] array in C# that gets returned from
I have an array in Perl: my @my_array = (one,two,three,two,three); How do I remove
I have an array of numbers that potentially have up to 8 decimal places
I have an array of a few million numbers. double* const data = new
I have an array of hashes, and I want the unique values out of
From what information I could find, they both solve the same problems - more

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.