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

128
Visualizações
Generating a alphanumeric values in series

I would like to generate a alphanumeric series in the fashion - AA0AAA00

The next would be AA0AAA01, AA0AAA02 ... AA0AAA99, AA0AAB00, AA0AAB01....AA0AAZ99, AA0ABA00 upto ZZ9ZZZ99

I have tried with

var start = "AA0AAA00"
var current = start
while (start != "ZZ9ZZZ99")
{
    current = current + 1
    console.log(current)
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here is a recursive generator solution. First it translates the pattern to ranges of "digits" for each position, and then the recursion iterates each character in the range for the first position and leaves the rest to the recursion.

For the example run I just took the pattern "A0" so to limit the size of the output here:

function* gen(start) {
    let ranges = Array.from(start, ch =>
        ch == "0" ? "0123456789" : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    );
    
    function* recur(range, ...rest) {
        if (!rest.length) return yield* range;
        for (let ch of range) {
            for (let out of recur(...rest)) {
                yield ch + out;
            }
        }
    }
    
    yield* recur(...ranges);
}

console.log([...gen("A0")]);

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