Results 1 to 11 of 11
Thread: Other Test?!
- 08-28-2011, 12:09 AM #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?
- 08-28-2011, 12:53 AM #2
What program generates that message?it say other tests are wrong !
What are the Strings it passes to your code?
- 08-28-2011, 01:13 AM #3
i solve problems of codingbat and this problem is this:
http://codingbat.com/prob/p192570Last edited by HearT.Hunt3r; 08-28-2011 at 01:15 AM.
- 08-28-2011, 01:49 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?
- 08-28-2011, 01:40 PM #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!
- 08-28-2011, 01:47 PM #6
Why do you think anyone here would know?i wanna know that what example don't work with my code!
- 08-28-2011, 01:49 PM #7
because i asked a question before and one person knew that... anyway thx.
- 08-28-2011, 02:53 PM #8
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, 03:25 PM #9
no i didn't
- 08-28-2011, 03:55 PM #10
That would be one way to find the problem in your program.
- 08-28-2011, 04:21 PM #11
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
From the help page on that site:
Reading helps ...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,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Is it possible to test for NaN?
By AJArmstron@aol.com in forum New To JavaReplies: 7Last Post: 05-07-2010, 02:22 AM -
Test Advisory Panel-Telecommute- Test your Java skills + share insights on Java tests
By michelle in forum Jobs OfferedReplies: 0Last Post: 04-05-2008, 12:38 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks