LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 701 users online 192297 members 1998 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Dictionary | News | FAQ
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
7 online / 34 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

wtf...java
Replies: 8Last Post Nov. 12, 2008 8:49pm by matto
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( matto )


Soothsayer

Patron
Tech Support Leader
Reply
So I'm doing this problem, and I've entered the code:
Code:
public int strDist(String str, String sub) {
 if( str.length()==0 ) return 0;
 if( !(str.substring(0, sub.length()).equals(sub)) ) {
   return strDist( str.substring(1, str.length()), sub);
 }
 if( !( str.substring( str.length()-sub.length(), str.length()).equals(sub) ) ) {
   return strDist( str.substring(0, str.length()-1), sub);
 }
 return str.length();
}
And it passes all the tests except "other tests," which isn't useful since I don't know what's causing it to break.  Any ideas?  This is not kewl.  :(

-------
"You're a bold kid, Arnold.
A bold kid."
--Gerald

8:04 pm on Nov. 12, 2008 | Joined Aug. 2007 | 309 Days Active
Join to learn more about matto California, United States | Bi-curious Male | 6304 Posts | 11940 Points
glowinthedark


Soothsayer

Sustainer
Reply
i thought this was about coffee..

dang it!

-------
Caution when hot.
You've given me strength to find hope.
Don't pretend to care. Don't apologize.
Sick MEGA porn.


8:06 pm on Nov. 12, 2008 | Joined June 2007 | 275 Days Active
Join to learn more about glowinthedark Japan | Metrosexual Female | 4845 Posts | 10767 Points
bratalvarado


Quality Control Engineer
Reply
wait what is this about

-------
im the vampire not u others, ill bite u

8:08 pm on Nov. 12, 2008 | Joined Nov. 2008 | 21 Days Active
Join to learn more about bratalvarado Colorado, United States | Straight Female | 545 Posts | 766 Points
Majo


Soothsayer
Reply
I wish I understood that but Java I kicked my ass, sorry.

-------
"Under the hardness of her facade a woman's heart is still beating."

8:09 pm on Nov. 12, 2008 | Joined May 2005 | 287 Days Active
Join to learn more about Majo Pennsylvania, United States | Straight Female | 6541 Posts | 11403 Points
h a t t


Guru

Sustainer
Reply
well i ran it in eclipse and it got the results it was looking for so i don't know what the X is about.

-------
i live low enough so the moon won't waste its light on me
LW Greasemonkey Repository
#igloos chat

8:30 pm on Nov. 12, 2008 | Joined June 2008 | 188 Days Active
Join to learn more about h a t t Ontario, Canada | Straight Male | 5380 Posts | 24975 Points
( matto )


Soothsayer

Patron
Tech Support Leader
Reply
yawtf.  I'm trying to come up with a situation that'd cause it to fail... can't think of anything.

-------
"You're a bold kid, Arnold.
A bold kid."
--Gerald

8:32 pm on Nov. 12, 2008 | Joined Aug. 2007 | 309 Days Active
Join to learn more about matto California, United States | Bi-curious Male | 6304 Posts | 11940 Points
h a t t


Guru

Sustainer
Reply
ah. it fails if the string doesn't contain the other string anywhere.

-------
i live low enough so the moon won't waste its light on me
LW Greasemonkey Repository
#igloos chat

8:35 pm on Nov. 12, 2008 | Joined June 2008 | 188 Days Active
Join to learn more about h a t t Ontario, Canada | Straight Male | 5380 Posts | 24975 Points
h a t t


Guru

Sustainer
Reply
just added

if (str.indexOf(sub) == -1 ) return 0;

to the top and it works
(when the index is -1 it means that the string is nowhere to be found)

Post edited at 8:41 pm on Nov. 12, 2008 by h a t t

-------
i live low enough so the moon won't waste its light on me
LW Greasemonkey Repository
#igloos chat


8:40 pm on Nov. 12, 2008 | Joined June 2008 | 188 Days Active
Join to learn more about h a t t Ontario, Canada | Straight Male | 5380 Posts | 24975 Points
( matto )


Soothsayer

Patron
Tech Support Leader
Reply
o snap alright.  thanks.  that's a useful method....

-------
"You're a bold kid, Arnold.
A bold kid."
--Gerald

8:49 pm on Nov. 12, 2008 | Joined Aug. 2007 | 309 Days Active
Join to learn more about matto California, United States | Bi-curious Male | 6304 Posts | 11940 Points
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic