![]() Which leads me to some Java code: long result = 0 Now this can be generalized to say that the left-most number would contribute (1-26)*27^(len-1), the next (1-26)*27^(len-2), and so on, until (1-26)*27^0. So, essentially, the left-most character contributes a value 27*(1-26) (for a-z) and the next character to the right, if one exists, contributes 1-26 (for a-z) to the value for a string. Let's assume we know this number.įor algorithmic simplicity, we would prefer to start at 27: (feel free to try to figure it out for starting from 0, you'll need some special cases) String Value Now, by just looking at that, you should be able to appreciate that, to determine the offset of any given shorter-length string, you'd need the maximum length allowed. Let's assign numbers up to length 2 strings: String Value I need to know if there exist an algorithm that can do the above.įor simplicity, I'll assume a to z are the only characters allowed in words. However if the data is suddenly increased or decreased then sorted A, AA, AAB, C, D, DA, DZ, E, FĮach word must have a unique independent integral equivalent and has the corresponding weights. The above letters has each corresponding index, E has the index of 4 ![]() The reason why I'm not using an increment index is for security purposes and is due to the indexes dependency to the number of data in the set The purpose of this application is to serve similar to an index or primary key. ![]() I'm trying to develop a system that can change my string into a unique integral value, meaning say for example the word "account" has an encrypted numerical value of 0891 and no other word can possibly be converted to 0891 with the same conversion process, it does not however need to be able to be converted back the generated integer to string.Īt the same time it will be dependent on the word structure rules, meaning words such as "accuracy" and "announcement" will have a generated number greater than 0891 and words such as "a", "abacus" and "abbreviation" will have a generated number less than 0891.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |