LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 547 users online 211077 members 1033 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Catacomb
Died in 1937
Days Active: 188
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
6 online / 26 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 )


Enlightened One

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.  :(

-------
"Strong am I with the Force, but not that strong.
Twilight is upon me, and soon, night must fall.
That is the way of things. The way of the Force."
--Yoda

8:04 pm on Nov. 12, 2008 | Joined: Aug. 2007 | Days Active: 434
Join to learn more about matto California, United States | Male | Posts: 8,807 | Points: 16,774
glowinthedark


Soothsayer

Patron
Reply
i thought this was about coffee..

dang it!

-------
Caution when hot.
I'm sick of looking for those heroes in the sky...
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Show me those pearly whites.


8:06 pm on Nov. 12, 2008 | Joined: June 2007 | Days Active: 342
Join to learn more about glowinthedark Japan | Metrosexual Female | Posts: 5,371 | Points: 13,859
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 | Days Active: 26
Join to learn more about bratalvarado Colorado, United States | Straight Female | Posts: 545 | Points: 816
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 | Days Active: 298
Join to learn more about Majo Pennsylvania, United States | Straight Female | Posts: 6,733 | Points: 11,716
h a t t


Enlightened One

Patron
Tech Support Leader
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.

-------
#igloos chat

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


Enlightened One

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.

-------
"Strong am I with the Force, but not that strong.
Twilight is upon me, and soon, night must fall.
That is the way of things. The way of the Force."
--Yoda

8:32 pm on Nov. 12, 2008 | Joined: Aug. 2007 | Days Active: 434
Join to learn more about matto California, United States | Male | Posts: 8,807 | Points: 16,774
h a t t


Enlightened One

Patron
Tech Support Leader
Reply
ah. it fails if the string doesn't contain the other string anywhere.

-------
#igloos chat

8:35 pm on Nov. 12, 2008 | Joined: June 2008 | Days Active: 302
Join to learn more about h a t t Ontario, Canada | Straight Male | Posts: 9,365 | Points: 16,295
h a t t


Enlightened One

Patron
Tech Support Leader
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

-------
#igloos chat


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


Enlightened One

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

-------
"Strong am I with the Force, but not that strong.
Twilight is upon me, and soon, night must fall.
That is the way of things. The way of the Force."
--Yoda

8:49 pm on Nov. 12, 2008 | Joined: Aug. 2007 | Days Active: 434
Join to learn more about matto California, United States | Male | Posts: 8,807 | Points: 16,774
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