1. ## 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 :
Java 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?

2. it say other tests are wrong !
What program generates that message?
What are the Strings it passes to your code?

3. i solve problems of codingbat and this problem is this:
http://codingbat.com/prob/p192570
Last edited by HearT.Hunt3r; 08-28-2011 at 01:15 AM.

4. 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?

5. 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!

6. i wanna know that what example don't work with my code!
Why do you think anyone here would know?

7. because i asked a question before and one person knew that... anyway thx.

8. Have you tried making your own testing driver and given it every possible combination of inputs and checked that the output is correct?

9. no i didn't

10. That would be one way to find the problem in your program.

11. From the help page on that site:

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.

kind regards,

Jos

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•