You are part of a team that is working on a piece of software to handle text compression. Your team
has designed the compression algorithm as follows:
To compress a given string of text, two strings, each 3 characters in length, will be chosen as
compression keys. The strings may contain any combination of capital letters and/or spaces. Then, a compressed string will be generated from the original such that replacing
"*1" in the compressed string with the first string and replacing "*2" with the second string will recreate the original text.
For example, if the two compression keys are "FOO" and "BAR", then the compressed string
"*2X*1" would decompress to "BARXFOO", and "*1*1 *2" would decompress to "FOOFOO BAR".
You have been tasked with writing a proof of concept implementation to test the effectiveness
of this compression scheme. You will be given a String original. Your goal
is to optimally select the two compression keys, and generate the compressed text to be as short as
possible. You are to return the length of the shortest possible text. |