How to get rid of duplicated characters in a string - page 3

 
Alain Verleyen:

Actually, I am wondering what is the exact specification you want.

Because the code provided by @Chris70 is bugged (for sure).

And the one provided by @Lorentzos Roussos maybe too

 TEST 1 : ahjzhhhz8128 => ajhz128 (Chris) : ahjz812 (Lorentzos)

I assume there is some "pattern blurring" taking place  

 

ahjzhhhz8128 => ajhz128 (Chris)   well.. no duplicates, no characters missing, he just didn't mention which duplicates are to be removed.... the pattern blurring was just my abstract art statement  ;-)

 
Chris70:

ahjzhhhz8128 => ajhz128 (Chris)   well.. no duplicates, no characters missing, he just didn't mention which duplicates are to be removed.... the pattern blurring was just my abstract art statement  ;-)

ehehehe ."Pattern Blurring" was for why the code is needed by the OP :)
Your code is fine der Arbeitskollege

 
Alain Verleyen:

Actually, I am wondering what is the exact specification you want.

Because the code provided by @Chris70 is bugged (for sure).

And the one provided by @Lorentzos Roussos maybe too

 TEST 1 : ahjzhhhz8128 => ajhz128 (Chris) : ahjz812 (Lorentzos)

actually the order of the characters doesn't matter to me in this case. 
I just needed to remove the duplicate characters and as you just tested, they both work well in that matter. and I didn't ask for the order of reminded characters. so both codes are cool for my use.

it is just fascinating to me how you guys deal with the algorithms. 

 
babigaf:

actually the order of the characters doesn't matter to me in this case. 
I just needed to remove the duplicate characters and as you just tested, they both work well in that matter. and I didn't ask for the order of reminded characters. so both codes are cool for my use.

it is just fascinating to me how you guys deal with the algorithms. 

Then all is fine, my understanding of the specs was bugged  :-)
 

I know the task was solved, so just for completeness and the fun of the brain teaser... 

The "bug" resulted from cutting out the first finding of two duplicate characters instead of the one that appears later in the string, so reading the characters in reverse order makes everybody happy ;-)

string StringRemoveDuplicates(string source)
  {
   for (int n=StringLen(source)-1;n>0;n--)
     {
      while (StringFind(StringSubstr(source,0,n),StringSubstr(source,n,1),0)!=-1)
        {source=StringSubstr(source,0,n)+StringSubstr(source,n+1);}
     }
   return source;
  }

TEST 1 : ahjzhhhz8128 => ahjz812 (Chris) : ahjz812 (Lorentzos)

 
Chris70:

I know the task was solved, so just for completeness and the fun of the brain teaser... 

The "bug" resulted from cutting out the first finding of two duplicate characters instead of the one that appears later in the string, so reading the characters in reverse order makes everybody happy ;-)

TEST 1 : ahjzhhhz8128 => ahjz812 (Chris) : ahjz812 (Lorentzos)

very nice +++

 
Chris70:

I know the task was solved, so just for completeness and the fun of the brain teaser... 

The "bug" resulted from cutting out the first finding of two duplicate characters instead of the one that appears later in the string, so reading the characters in reverse order makes everybody happy ;-)

TEST 1 : ahjzhhhz8128 => ahjz812 (Chris) : ahjz812 (Lorentzos)

Actually, the while loop is now useless, you can just use "if".
 

OMG

I love you there :D