Home > OS >  I need the algorithm for suggesting other similar usernames
I need the algorithm for suggesting other similar usernames

Time:10-05

I am looking for an algorithm which will replicate one of Instagrams features.

When you create an Instagram account, you need to take a unique username

If you take a unique username, great, everything is fine.

If you take an existing username, it suggest other very similar usernames.

I am looking for an algorithm to suggest other possible usernames, which are also not found in the database.

For example:

User enters: cool1

Let's say this username has been taken, I would need to find a way to suggest something along the lines of:

coool1 coolll1 col1 cool111 etc etc....

CodePudding user response:

Just add random characters to the end until it is unique.

Just don't do anything sequential and predictable. Because then you'll get into the situation that the 1000th person to attempt to register "cool" triggers 1000 tries in a row before finding one. While adding random digits will still only need 3-4.

  • Related