LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 693 users online 221763 members 882 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
ElmoAmazing
Cool Things: Smoking xD Having Fun With Friend...
Mood: Honest
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
4 online / 37 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 )


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

-------
"Say what you like about the tenets of National Socialism, Dude,
at least it's an ethos."
--Walter Sobchak

8:04 pm on Nov. 12, 2008 | Joined: Aug. 2007 | Days Active: 490
Join to learn more about matto California, United States | Male | Posts: 9,823 | Points: 19,085
LiveWire Humor
glowinthedark


Guru

Sustainer
Reply
i thought this was about coffee..

dang it!

-------
i lie here
paralytic
inside this soul..


8:06 pm on Nov. 12, 2008 | Joined: June 2007 | Days Active: 419
Join to learn more about glowinthedark Japan | Metrosexual Female | Posts: 6,211 | Points: 24,965
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: 27
Join to learn more about bratalvarado Colorado, United States | Straight Female | Posts: 545 | Points: 826
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: 301
Join to learn more about Majo Pennsylvania, United States | Straight Female | Posts: 6,733 | Points: 10,531
h a t t



Patron
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: 304
Join to learn more about h a t t Ontario, Canada | Straight Male | Posts: 9,360 | Points: 31,944
( matto )


Omnipotent 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.

-------
"Say what you like about the tenets of National Socialism, Dude,
at least it's an ethos."
--Walter Sobchak

8:32 pm on Nov. 12, 2008 | Joined: Aug. 2007 | Days Active: 490
Join to learn more about matto California, United States | Male | Posts: 9,823 | Points: 19,085
h a t t



Patron
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: 304
Join to learn more about h a t t Ontario, Canada | Straight Male | Posts: 9,360 | Points: 31,944
h a t t



Patron
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: 304
Join to learn more about h a t t Ontario, Canada | Straight Male | Posts: 9,360 | Points: 31,944
( matto )


Omnipotent One

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

-------
"Say what you like about the tenets of National Socialism, Dude,
at least it's an ethos."
--Walter Sobchak

8:49 pm on Nov. 12, 2008 | Joined: Aug. 2007 | Days Active: 490
Join to learn more about matto California, United States | Male | Posts: 9,823 | Points: 19,085
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