Register to reply

How to convert a username to a 2 digit number?

by Erazman
Tags: convert, digit, number, username
Share this thread:
Erazman
#1
Jan8-14, 08:52 PM
P: 64
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.
Phys.Org News Partner Mathematics news on Phys.org
Researcher figures out how sharks manage to act like math geniuses
Math journal puts Rauzy fractcal image on the cover
Heat distributions help researchers to understand curved space
Simon Bridge
#2
Jan8-14, 08:59 PM
Homework
Sci Advisor
HW Helper
Thanks
Simon Bridge's Avatar
P: 13,083
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.
pwsnafu
#3
Jan9-14, 12:50 AM
Sci Advisor
P: 839
Quote Quote by Erazman View Post
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.

Borek
#4
Jan9-14, 03:09 AM
Admin
Borek's Avatar
P: 23,719
How to convert a username to a 2 digit number?

http://en.wikipedia.org/wiki/Hashing_function


Register to reply

Related Discussions
Does the first two-digit number have to be 10? General Math 27
4 digit number knowing one number Fun, Photos & Games 2
Four digit number, digit increasing/decreasing in size Precalculus Mathematics Homework 2
(4-digit number)*(6-digit number) equals a factorial Fun, Photos & Games 1
4 digit number... General Math 4