How to convert a username to a 2 digit number?

  • Context: High School 
  • Thread starter Thread starter Erazman
  • Start date Start date
  • Tags Tags
    Convert
Click For Summary

Discussion Overview

The discussion revolves around methods for converting a username into a two-digit number ranging from 10 to 99. Participants explore various approaches and considerations related to the uniformity and simplicity of the conversion process.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • One participant suggests assigning numbers to usernames randomly or in the order they appear, starting at 10 and cycling at 99.
  • Another proposes adding the ASCII values of all characters in the username and taking the lowest two digits for the resulting number.
  • A different participant questions the choice of starting at 10 instead of 00 and notes that a deterministic method would require usernames to be uniformly distributed.
  • This participant also suggests taking the last two letters of the username, treating them as a base-26 number, and then applying modulo 90 to fit the desired range.
  • They express frustration with the algorithm, stating that modifications reveal inconsistencies.
  • A link to a Wikipedia page on hashing functions is provided, possibly as a reference for further exploration.

Areas of Agreement / Disagreement

Participants express differing opinions on the starting point for the number range and the feasibility of achieving a uniform distribution. There is no consensus on a single method, and multiple competing approaches are presented.

Contextual Notes

Participants highlight the need for simplicity in the conversion method and the challenges associated with ensuring a uniform distribution of usernames. There are unresolved issues regarding the effectiveness of proposed algorithms.

Erazman
Messages
65
Reaction score
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
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.
 
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:

Similar threads

  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K
Replies
11
Views
6K
Replies
17
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K