Author |
Topic: compress string (Read 842 times) |
|
algo_wrencher
Newbie

 I am not insane, I enjoy every moment of it!
Posts: 44
|
 |
compress string
« on: Feb 4th, 2006, 2:06am » |
Quote Modify
|
Lets say I have a string as: "abbabccbc". It has to be compressed so that it first will become "ababcbc", then becomes "abc". Similarly, "abcaab" will become "abcab" and but stays as it is after that. in short first i compare single chars, then 2 chars and so on.... How can I do it efficiently?
|
|
IP Logged |
|
|
|
Grimbal
wu::riddles Moderator Uberpuzzler
    

Gender: 
Posts: 7527
|
 |
Re: compress string
« Reply #1 on: Feb 4th, 2006, 9:04am » |
Quote Modify
|
What is the rule, exactly? Do you repeatedly delete any repetition, whatever the length, as long as there is no other character in between?
|
|
IP Logged |
|
|
|
algo_wrencher
Newbie

 I am not insane, I enjoy every moment of it!
Posts: 44
|
 |
Re: compress string
« Reply #2 on: Feb 4th, 2006, 11:09am » |
Quote Modify
|
adjacent subdtrings of any length that are same must be killed. abcabc qould yield abc abababcdcd-> abcd aaaa->a abbaccbd->abbacbd and so on... but abcdabc would remain as it as the d lies between the same substrings..
|
|
IP Logged |
|
|
|
|