# Other Test?!

• 08-28-2011, 01:09 AM
HearT.Hunt3r
Other Test?!
This is Problem : Given two strings, base and remove, return a version of the base string where all instances of the remove string have been removed (not case sensitive). You may assume that the remove string is length 1 or more. Remove only non-overlapping instances, so with "xxx" removing "xx" leaves "x".

withoutString("Hello there", "llo") → "He there"
withoutString("Hello there", "e") → "Hllo thr"
withoutString("Hello there", "x") → "Hello there"

=====================
and this is my answer :
Code:

```public String withoutString(String base, String remove) {                  String r = remove.toLowerCase() ;                 String b = remove.toUpperCase();                 String res = "";                 for(int i=0;i<base.length();i++){                         int v = base.indexOf(r,i);                         if(v<0) {                                 res+= base.substring(i, base.length());                                 break;                         }else{                         res += base.substring(i,v);                         }                         i = v+r.length()-1;                 }                 String fres = res;                 String rr="";                 for(int z=0;z<fres.length();z++){                         int g = fres.indexOf(b,z);                         if(g<0){                                 rr += fres.substring(z, fres.length());                                 break;                         }else{                                 rr += fres.substring(z, g);                         }                         z = g+b.length()-1;                 }                 return rr;                        }```
====================
and this is results :
withoutString("Hello there", "llo") → "He there" "He there" OK
withoutString("Hello there", "e") → "Hllo thr" "Hllo thr" OK
withoutString("Hello there", "x") → "Hello there" "Hello there" OK
withoutString("This is a FISH", "IS") → "Th a FH" "Th a FH" OK
withoutString("THIS is a FISH", "is") → "TH a FH" "TH a FH" OK
withoutString("THIS is a FISH", "iS") → "TH a FH" "TH a FH" OK
withoutString("abxxxxab", "xx") → "abab" "abab" OK
withoutString("abxxxab", "xx") → "abxab" "abxab" OK
withoutString("abxxxab", "x") → "abab" "abab" OK
withoutString("xxx", "x") → "" "" OK
withoutString("xxx", "xx") → "x" "x" OK
withoutString("xyzzy", "Y") → "xzz" "xzz" OK
withoutString("", "x") → "" "" OK
withoutString("abcabc", "b") → "acac" "acac" OK
other tests X

=======================
it say other tests are wrong ! what can be other tests?
• 08-28-2011, 01:53 AM
Norm
Quote:

it say other tests are wrong !
What program generates that message?
What are the Strings it passes to your code?
• 08-28-2011, 02:13 AM
HearT.Hunt3r
i solve problems of codingbat and this problem is this:
http://codingbat.com/prob/p192570
• 08-28-2011, 02:49 AM
Norm
Can you add printlns to print out what Strings are passed to your code that you are not correctly processing?

How do you know that the output from the testing program is correct?
• 08-28-2011, 02:40 PM
HearT.Hunt3r
this site has a compiler that do the same job... and i checked my answers and they was correct.
i haven't other tests! and i wanna know that what example don't work with my code!
• 08-28-2011, 02:47 PM
Norm
Quote:

i wanna know that what example don't work with my code!
Why do you think anyone here would know?
• 08-28-2011, 02:49 PM
HearT.Hunt3r
because i asked a question before and one person knew that... anyway thx.
• 08-28-2011, 03:53 PM
Norm
Have you tried making your own testing driver and given it every possible combination of inputs and checked that the output is correct?
• 08-28-2011, 04:25 PM
HearT.Hunt3r
no i didn't
• 08-28-2011, 04:55 PM
Norm
That would be one way to find the problem in your program.
• 08-28-2011, 05:21 PM
JosAH
From the help page on that site:

Quote:

There may be a few "other tests" listed at the bottom of the table but which are not detailed -- these additional tests are similar to the ones shown in the table, but with different numbers, strings, etc. filled in.