How to convert a username to a 2 digit number?

  • Thread starter Erazman
  • Start date
  • Tags
    Convert
In summary, there are various methods suggested for converting a username into a number between 10 and 99, including assigning numbers randomly, assigning numbers in order of appearance, and using the ASCII values of the characters. However, it is difficult to ensure a uniform distribution of numbers and a simple method for conversion. Hashing functions may be a more reliable option.
  • #1
Erazman
66
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.
 
Mathematics news on Phys.org
  • #2
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
Erazman said:
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:
  • #5


I would approach this problem by first considering the limitations and parameters of the task. It is important to clarify what constitutes a valid username and what characters or symbols may be present in a username. Additionally, it would be helpful to know if there are any specific rules or patterns that should be followed in converting the username to a number.

One possible approach could be to assign a numerical value to each letter in the alphabet, starting with A=1, B=2, C=3, and so on. This would allow for a simple and consistent conversion process. However, this method may not account for special characters or symbols that may be present in a username.

Another approach could be to use a mathematical formula or algorithm to convert the username to a number. This could involve taking the sum of the numerical values of each letter in the username and then manipulating the resulting number to fit within the desired range of 10-99. This method may require more effort and calculation, but it can be more flexible in accounting for different types of usernames.

Ultimately, the best method for converting a username to a 2 digit number will depend on the specific requirements and constraints of the task. I would suggest experimenting with different approaches and evaluating their effectiveness in meeting the desired criteria. This may involve testing the method with a variety of usernames and adjusting it as needed to achieve a balanced distribution of numbers between 10 and 99.
 

1. How can I convert a username to a 2 digit number?

There are many ways to convert a username to a 2 digit number, but one simple method is to assign each letter in the username a corresponding number (A=1, B=2, C=3, etc.) and then add up the numbers. If the sum is more than 99, you can take the last two digits as your 2 digit number.

2. Can I use any username to convert to a 2 digit number?

Yes, you can use any username to convert to a 2 digit number. However, keep in mind that longer usernames may result in a higher 2 digit number, while shorter usernames may result in a lower 2 digit number.

3. Is there a specific formula for converting a username to a 2 digit number?

No, there is no specific formula for converting a username to a 2 digit number. The method used may vary depending on personal preferences or the specific requirements of the project.

4. Can I use special characters in the username when converting to a 2 digit number?

Yes, you can use special characters in the username when converting to a 2 digit number. However, you may need to assign the special characters a corresponding number to include them in the conversion process.

5. Why would I need to convert a username to a 2 digit number?

Converting a username to a 2 digit number can be useful in certain situations, such as creating unique identifiers or codes for users. It can also be a fun and creative way to represent a username in a numerical form.

Similar threads

Replies
4
Views
2K
Replies
10
Views
1K
Replies
12
Views
2K
Replies
4
Views
908
Replies
2
Views
2K
  • General Math
Replies
2
Views
1K
  • Electrical Engineering
3
Replies
78
Views
3K
Replies
8
Views
2K
Back
Top