I'm working on a simple game and I have the requirement of taking a word or phrase such as "hello world" and converting it to a series of numbers.
The criteria is:
- Numbers need to be distinct
- Need ability to configure maximum sequence of numbers. IE 10 numbers total.
- Need ability to configure max range for each number in sequence.
- Must be deterministic, that is we should get the same sequence everytime for the same input phrase.
I've tried breaking down the problem like so:
- Convert characters to ASCII number code: "hello world" =
104 101 108 108 111 32 119 111 114 108 100
- Remove everyother number until we satisfy total numbers (10 in this case)
- Foreach number if number > max number then divide by 2 until number <= max number
- If any numbers are duplicated increase or decrease the first occurence until satisfied. (This could cause a problem as you could create a duplicate by solving another duplicate)
Is there a better way of doing this or am I on the right track? As stated above I think I may run into issues with removing distinction.