I need to achieve string compression to a certain length.
The input is a string consisting of 3 to 16 characters, which can include the English alphabet in lowercase, numbers (0-9) and underlines (or regex: ^[a-z-z0-9_]{3,16}$
).
The English alphabet in any case, numbers, underlines, brackets and other various utf8 characters can be used to compress the original string. The compressed string must support the reverse process: from the compressed string to the original string.
In my case, the specific length of the compressed string is 6. However, I do not know if it is possible to compress a 16 character string into a “6 character code”. If this is not possible, then I suggest increasing it to 7-8 characters.
Example:
input: bestnickname
output: D_1(oP
I’ve been trying to find various algorithms to solve this problem, but I haven’t found one.