|
|
Subject:
Algorithms
Category: Computers > Algorithms Asked by: ace24-ga List Price: $4.00 |
Posted:
26 Mar 2003 21:35 PST
Expires: 25 Apr 2003 22:35 PDT Question ID: 181583 |
What techniques can be used to convert a 20 character unique number into 'say' 8 character unique code (involving alphabet characters and number characters if required) | |
| |
| |
| |
| |
|
|
There is no answer at this time. |
|
Subject:
Re: Algorithms
From: xarqi-ga on 26 Mar 2003 21:56 PST |
None. |
Subject:
Re: Algorithms
From: denco-ga on 26 Mar 2003 22:51 PST |
If one is allowed to use an extended character set (extended ASCII keys, such as é) then maybe you could use a modified Base-N (where n would be some "large" number such as 36 or larger?) to extend the base-n number to reduce the answer to the 8 character limit. 99999999999999999999 = L3R41IFS0QO40 in Base-36 If you then replaced all of the "L3" (for instance) in the resulting Base-36 "numbers" with, say, ! it might work. I don't know if there are enough extended characters for it to work. Up to 12 character or so numbers, Base-36 by itself would suffice, and up to 16 characters numbers you could use an extended character set scheme. I don't know though, Base-N work makes my head hurt. denco-ga |
Subject:
Re: Algorithms
From: carnegie-ga on 27 Mar 2003 08:38 PST |
Dear Ace24, May I expand a little on Xarqi's accurate comment? As Maniac wrote, representing the required number of entities in a sufficiently short code requires a sufficiently large character set. Assuming your numbers are indeed of 20 _decimal_ digits, there are 10 to the power 20 of them to consider. In order to represent all these by an 8-character code, you need an n-character set, where n is given by: n^8 = 10^20 Taking logarithms of both sides: ln(n^8) = ln(10^20) 8 ln(n) = ln(10^20) ln(n) = ln(10^20)/8 n = exp(ln(10^20)/8) The solution to this is a little over 316, so you need a set of 317 characters to achieve your requirement. If you remember that an 8-bit byte can carry 256 states, you will realise that this is quite large. But it is feasible as long as you can select 317 characters that your readers will recognise and easily differentiate. If your 20-digit number cannot take all possible values, you could get away with a smaller character set at the expense of a more complicated conversion algorithm. I trust this helps. Carnegie |
Subject:
Re: Algorithms
From: denco-ga on 27 Mar 2003 09:11 PST |
If "all" you are trying to do is to have some kind of "coding" system wherein a 20 digit sequence can be reduced to a 8 character (one that might go outside the sphere of "just" numbers/letters) sequence, I've come up with 2 unorthodox schemes to reduce it to 7 characters, yet still be readable. I am sure there more ways possible as well. |
Subject:
Re: Algorithms
From: xarqi-ga on 27 Mar 2003 20:23 PST |
At the risk of being cryptic, rather than terse: To map a sparse address space into a denser one, use a hash function. |
Subject:
Re: Algorithms
From: carnegie-ga on 28 Mar 2003 04:11 PST |
Dear Ace24, You now say that your input can be up to 30 digits long and that you wish to restrict the output code to numeric and alphabetic characters. There is a little danger here, of course, as if the codes are to be read by humans there will be confusion between 1 and I and between 0 and O. You do not say whether you wish to use, say, all capitals or a mixture of capital and lower case. Using lower case, of course, would add the confusion between 1, I, and l! Just to give you some idea of the length, similar calculations to my earlier one tell us that reducing a general 30-digit decimal number to a combination of digits and capital letters (a 36-character set) would need a 20-character code, and reducing it to a combination of digits, capital letters, and lower case letters (a 62-character set) would require a 17-character code. One thing you should look at carefully is whether the input number can take all posible 30-digit values - all one million million million of them. If not, it will be possible - by using a more sophisticated algorithm - to shorten the resulting code. I trust this helps. Carnegie |
Subject:
Re: Algorithms
From: denco-ga on 31 Mar 2003 18:49 PST |
Howdy ace24! - Is it possible for you to elaborate on two unorthodox techniques you have come up with. Well, if the intent of the coding is (for instance) to present to a viewer a way of discerning a 20 character number: 12345678901234567890 from a (in this scheme) a 7 character "object" wherein the actual 20 character number would not be readily discernable to someone that was not aware that there was coding system in place, then: You create a custom set of new objects; these objects have the visual aspect of numbers, but with additional information coded in a visual manner as part of the objects. This encoding could be of a format that Optical Character Recognition (OCR) would be able to read, as well as (with minimal training) human beings. The first scheme (and there are probably more ways to do this) would be in the form of (as an example) a black box with a white number in the center, with white "notches" along the left, right and maybe the top and bottom sides of the boxes. So, to represent the number 999 you would have a black box with a white 9 in the center, and 9 white notches arranged across the top and left sides, and nine white notches along the right and bottom sides. You then break the 20 character number into 6 sets of 3 characters and 1 set of 2 characters and encode each set with the above style of characters. The second scheme is similar (except not as "elegant") except it uses color and font differences for the encoding. One could borrow the color code from the electronic part of resistors, wherein the color brown is a 1, the color red is a 2, etc. The larger a font, the larger the number, so that 222 might be coded to be a red number 2 of a font size of 12. You could do a hybrid of both of the above; a red 7 in a box with 3 notches would represent 327. - Also can you also explain base-n approach. Here goes; to reduce your 20 digit character the first step, you can first reduce it in size by depicting it in another way, such as Base-36 (it starts out being depicted in Base-10), so: 99999999999999999999 = L3R41IFS0QO40 in Base-36 This gets us down to (as maniac points out) 13 digits. To further reduce this set, as this way of presenting digits does not include lower case letters or an extended character set, such as ñ or Ñ, etc. perhaps you could take subsets of the end product (L3R41IFS0QO40 above) and further encode sections. So 3R would be depicted by (for instance) an ampersand (&), with an end result of a 7 character encoding (the example is purely that): 99999999999999999999 = L3R41IFS0QO40 = L&e*SQd The problem with the Modified Base-N scheme (as carnegie points out in different ways) is that you would need 10 (the numbers times 26 (the alphabet) or 260 unique "other" characters for the second step of encoding. If you use the full extended character set you might have enough, but you end up with something like my first oddball method except tougher to encode and decode. Don't know if this help or just make things worse. Looking Forward, denco |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |