Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda