Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 interesting problem
Index -> General Programming
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
[Gandalf]




PostPosted: Tue Aug 16, 2005 2:58 pm   Post subject: (No subject)

It's actually a pretty straightforward problem, just look at the output for the examples. The result is the length of the compressed string. So instead of having BARXFOO you would have *2X*1 because *2 is BAR and *1 is FOO. "*2X*1" is 5 characters so that is what you would get as a result (as opposed to 7 characters without the compression).
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Aug 16, 2005 3:37 pm   Post subject: (No subject)

Of course, in reality, you have to add 6 characters to communicate what the keys are. Smile
[Gandalf]




PostPosted: Tue Aug 16, 2005 3:44 pm   Post subject: (No subject)

Yes, so it's only really a compression technique if there are more than one of the 'keys' in the string. You could also add detection for that, so that you don't make some file bigger instead of smaller Smile.
bugzpodder




PostPosted: Tue Aug 16, 2005 6:17 pm   Post subject: (No subject)

[Gandalf] wrote:
It's actually a pretty straightforward problem, just look at the output for the examples. The result is the length of the compressed string. So instead of having BARXFOO you would have *2X*1 because *2 is BAR and *1 is FOO. "*2X*1" is 5 characters so that is what you would get as a result (as opposed to 7 characters without the compression).


the more interesting case is when keys overlap.
such as for keys AAA and AAB
wtd




PostPosted: Tue Aug 16, 2005 7:46 pm   Post subject: (No subject)

bugzpodder wrote:
[Gandalf] wrote:
It's actually a pretty straightforward problem, just look at the output for the examples. The result is the length of the compressed string. So instead of having BARXFOO you would have *2X*1 because *2 is BAR and *1 is FOO. "*2X*1" is 5 characters so that is what you would get as a result (as opposed to 7 characters without the compression).


the more interesting case is when keys overlap.
such as for keys AAA and AAB


Yes, since "compressing" based on the first key inherently changes the result of "compressing" using the second key.
[Gandalf]




PostPosted: Tue Aug 16, 2005 10:10 pm   Post subject: (No subject)

Hmm, ya I see. What I would do though is just replace the first key, and then you have nothing to worry about since the overlap doesn't exist anymore Very Happy. Yes, me and my lazy ways...
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 21 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: