convert a number to the shortest possible character string while retaining uniqueness

Posted by alumb on Stack Overflow See other posts from Stack Overflow or by alumb
Published on 2010-04-01T00:52:57Z Indexed on 2010/04/01 1:33 UTC
Read the original article Hit count: 443

Filed under:
|
|

I have a list of digits, say "123456", and I need to map it to a string, any string. The only constraint on the map functions are:

  • each list of digits must map to a unique character string (this means the string can be arbitrarily long)
  • character string can only contain 0-9, a-z, A-Z

What map function would produce the shortest strings?

Solutions in JavaScript are preferred.

note: Clearly the simplest solution is to use the original list of digits, so make sure you solution does better than that.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about fun