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

208
Vistas
is it possible to create a collision free random string with just 10 alpha-numeric characters (all lower-case)?

Is it possible to create collision-free random 10 character alphanumeric string? It has to be all lower-case by the way. Bitly seemed to have solved it but I do know they use a combination of uppercase and lowercase that increases randomness. This has to be done with just one case though.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here's a function to randomize string and an honest attempt to find duplicates.

function random_str(length, possible) {
  var text = "";
  length = length || 5;
  possible = possible || "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  for (var i = 0; i < length; i++)
    text += possible.charAt(Math.floor(Math.random() * possible.length));
  return text;
};

var max = 1e4;
var i = 0;
var arr = [];
while (true) {
  var id = random_str(10, "abcdefghijklmnopqrstuvwxyz0123456789");
  console.log(id)
  if (arr.indexOf(id) > -1) {
    alert("end of universe");
    break;
  }
  arr.push(id);
  if (i++ >= max) {
    break;
  }
}

console.log("done. no duplicates found after " + i + " attempts")
.as-console-wrapper {
  max-height: 100% !important;
}

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