Praming Puzles & Colf: Condense a String Having spend some time on this site I have come to enjoy things being as short as possible. That may be the reason why I'm recently kind of offended by strings containing the same characters more than once. Your job is to write a function or program which condenses a given string according to the following rules:


Start with a 0-condensation, that is look for the first (leftmost) pair of the same characters with 0 other characters between them. If such a pair is found, remove one of the two characters and restart the algorithm by performing another 0-condensation. If no such pair is found, proceed with the next step. Examples:
  programming -C0-> programing
  aabbcc -C0-> abbcc
  test -C0-> test
Then perform a 1-condensation, that is look for the first pair of same characters with 1 other character between them. If such a pair is found remove one of them and all characters between them and restart with a 0-condensation. If no such pair is found, proceed with the next step. Examples:
abacac -C1-> acac
java -C1-> ja  
Continue with a 2-condensation and so on up to a n-condensation with n being the length of the original string, each time restarting after a condensation removed some letters. Examples:
programing -C2-> praming
abcdafg -C3-> afg


The resulting string is called condensed and contains each character at most once.



Input:  

A lower case string of printable ascii-characters.

Output:  

The condensed string according to the rules above.

Examples:

examples     -&gt; es
programming  -&gt; praming
puzzles      -&gt; puzles
codegolf     -&gt; colf
andromeda    -&gt; a
abcbaccbabcb -&gt; acb
if(x==1):x++ -&gt; if(x+
fnabnfun     -&gt; fun
abcdefae     -&gt; abcde


Detailed examples to clarify how the algorithm works:

fnabnfun -C0-&gt; fnabnfun -C1-&gt; fnabnfun -C2-&gt; fnfun -C0-&gt; fnfun -C1-&gt; fun -C0-&gt; fun 
 -C1-&gt; fun -C2-&gt; ... -C8-&gt; fun

abcbaccbabcb -C0-&gt; abcbacbabcb -C0-&gt; abcbacbabcb -C1-&gt; abacbabcb -C0-&gt; abacbabcb 
 -C1-&gt; acbabcb -C0-&gt; acbabcb -C1-&gt; acbcb -C0-&gt; acbcb -C1-&gt; acb -C0-&gt; acb 
 -C1-&gt; ... -C12-&gt; acb


Your approach doesn't have to implement the algorithm from above as long as your solution and the algorithm return the same output for all allowed inputs.
This is a code-golf challenge.



Thanks to @Linus for helpful sandbox comments!
JavaScript (ES6), 74 bytes



f=
(s,n=0,m=s.match(`(.).{${n}}\\1`))=&gt;s[n]?m?f(s.replace(...m)):f(s,n+1):s
;
&lt;input oninput=o.textContent=f(this.value)&gt;&lt;pre id=o&gt;