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

206
Views
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 answers
Answer question

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 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!