How to convert a username to a 2 digit number?


by Erazman
Tags: convert, digit, number, username
Erazman
Erazman is offline
#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
Math modeling handbook now available
Hyperbolic homogeneous polynomials, oh my!
Researchers help Boston Marathon organizers plan for 2014 race
Simon Bridge
Simon Bridge is offline
#2
Jan8-14, 08:59 PM
Homework
Sci Advisor
HW Helper
Thanks ∞
PF Gold
Simon Bridge's Avatar
P: 11,102
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
pwsnafu is offline
#3
Jan9-14, 12:50 AM
Sci Advisor
P: 779
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
Borek is offline
#4
Jan9-14, 03:09 AM
Admin
Borek's Avatar
P: 22,710

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 Brain Teasers 2
Four digit number, digit increasing/decreasing in size Precalculus Mathematics Homework 2
(4-digit number)*(6-digit number) equals a factorial Brain Teasers 1
4 digit number.... General Math 4