Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda