wu :: forums
« wu :: forums - compress string »

Welcome, Guest. Please Login or Register.
May 17th, 2024, 11:19pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Grimbal, SMQ, ThudnBlunder, william wu, towr, Icarus, Eigenray)
   compress string
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: compress string  (Read 836 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 Quote Modify 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: male
Posts: 7527
Re: compress string  
« Reply #1 on: Feb 4th, 2006, 9:04am »
Quote Quote Modify 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 Quote Modify 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
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board