How to convert a username to a 2 digit number?

  • Thread starter Erazman
  • Start date
  • #1
62
0
I am trying to figure out how to convert a username into a number between 10 to 99.
It would be preferable that a username will end up being 10 just as much as 99, covering the whole range without a tendency to be low or high..
This method needs to be a simple as possible so that someone can convert their name with little effort.
 

Answers and Replies

  • #2
Simon Bridge
Science Advisor
Homework Helper
17,857
1,655
1. Assign numbers to usernames randomly.
2. Assign numbers in order the users show up, starting at 10 and cycling at 99
3. add the ascii values of all the characters together, and take the lowest two digits for the number.
...
... there are so many ways.
 
  • #3
pwsnafu
Science Advisor
1,080
85
I am trying to figure out how to convert a username into a number between 10 to 99.
Why ten? Shouldn't it start at 00?

It would be preferable that a username will end up being 10 just as much as 99, covering the whole range without a tendency to be low or high..
If it is deterministically based on the username, this is unlikely. Usernames would need to be uniformly distributed to begin with.

This method needs to be a simple as possible so that someone can convert their name with little effort.
The only one I can think of would be: take the last two letters of the username and treat it as a base-26 number. Then modulo 90.

If the range was 00~99 then this would be much easier. Base-26 to Base-10 take last two digits.

Edit: ah, scratch it. No matter how many times I modify the algorithm I keep finding holes.
 
Last edited:

Related Threads on How to convert a username to a 2 digit number?

Replies
6
Views
4K
Replies
5
Views
3K
Replies
4
Views
24K
  • Last Post
Replies
5
Views
3K
Replies
3
Views
4K
Replies
4
Views
2K
  • Last Post
Replies
4
Views
831
  • Last Post
Replies
13
Views
4K
Replies
13
Views
958
Replies
1
Views
2K
Top