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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:17:07+00:00 2026-05-23T00:17:07+00:00

Givven an object with Key as an Array (of position) and Value as an

  • 0

Givven an object with Key as an Array (of position) and Value as an Array as well:

// Example Object
0,2 : [6, 8, 9]
0,3 : [1, 6, 8]
0,4 : [6, 8]
0,5 : [6, 8]
0,6 : [4, 5, 8, 9]
0,7 : [5, 8]
0,8 : [4, 5, 7, 9]

(it was created like this:

x = {};
x[[0,2]] = [6, 8, 9];
x[[0,3]] = [1, 6, 8];
...

Now, I want to narrow down my object to this, by checking if any number in an Array appears only inside this array, and not in others value’s arrays, then eliminating all the other numbers inside the specific array which holds the unique number.
(Rule: no duplicated inside a given array, so no need to check that):

// Result Object
0,2 : [6, 8, 9]
0,3 : [1]
0,4 : [6, 8]
0,5 : [6, 8]
0,6 : [4, 5, 8, 9]  // now 4 becomes also a "loner"
0,7 : [5, 8]
0,8 : [7]

so here in Key [0,3] the Value’s array was narrowed down to just [1] because 1 is a unique number not showing up in the other array.

I’m having trouble thinking of an efficient pattern for this…

  • 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-23T00:17:08+00:00Added an answer on May 23, 2026 at 12:17 am

    The idea here it that i go through every number in every array, and check it against
    a Bucket (string) which holds all the numbers from all the arrays, joined. if the first index of the current x[key][i] in the bucket is the SAME as the last index, it means this number is unique and, thus it’s holding array is reset to hold that number alone.

    var x = {};  // object
    
    x[[0,0]] = [6, 8, 9];
    x[[0,1]] = [1, 6, 8];
    x[[0,2]] = [6, 8];
    x[[0,3]] = [6, 8];
    x[[0,4]] = [4, 5, 8, 9];
    x[[0,5]] = [5, 8];
    x[[0,6]] = [4, 5, 7, 9];
    
    function findUniquePosibilites(x){
        var bucket = "";
        for(var key in x)
            bucket += x[key].join("");
    
        for(var key in x)
            for (var i = x[key].length; i--; ){
                var num = x[key][i];
                if( bucket.indexOf(num) ==  bucket.lastIndexOf(num) ){
                    x[key] = [num];
                    break;
                };
            }
    }
    
    findUniquePosibilites(x);
    console.dir( x );
    
    /*
    0,0 : [6, 8, 9] 
    0,1 : [1]
    0,2 : [6, 8]
    0,3 : [6, 8]    
    0,4 : [4, 5, 8, 9]  
    0,5 : [5, 8]    
    0,6 : [7]
    */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given an object like this: { name: joe } I want to get the
Given an Object: myObj = {key : 'value'} How do I get the key?
Given an object like this: var obj = { first:{ second:{ third:'hi there' }
given: class Widget { Object value; } interface WidgetMap { void put( Widget key,
I found the following statement: Map is an object that stores key/volume pairs. Given
I've got an array of Javascript objects that I'd like to cross-compatibly sort by
I am working on a function that receives an object organised in this manner:
Problem I need a key-value store that can store values of the following form:
I'm trying to use an object as a key in a python dictionary, but
I have a JSON string and I'd like to use to compose an object.

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.