Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
Generating a complete superset?

Given the input string NEIDESL, I need to generate a superset of every combination of letters this string contains. I've tried a good few answers from StackOverflow.

However, upon executing with my input string, none of the results contain the word DIESEL which leads to me believe they are not complete supersets.

I'm using the follow snippet, found from here:

function strcombinations(str) {
    var fn = function(active, rest, a) {
        if (!active && !rest)
            return;
        if (!rest) {
            a.push(active);
        } else {
            fn(active + rest[0], rest.slice(1), a);
            fn(active, rest.slice(1), a);
        }
        return a;
    }
    return fn("", str, []);
}

I may be misunderstanding what a superset is here, any help appreciated :)

Cheers

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

//Lets Try this code.

    const getAllSubsets = 
          theArray => theArray.reduce(
            (subsets, value) => subsets.concat(
             subsets.map(set => [value,...set])
            ),
            [[]]
          );
    
    console.log(getAllSubsets(['N','E','I','D','E','S','L']));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!