Ls chin

Ranch Hand
since Jun 28, 2008
For More
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

Recent posts by Ls chin

Hello Rob, Campbell,

Thank you both very much!
14 years ago

Originally posted by ramya narayanan:
Now i want others opinions about achieving financial independence or freedom? Do you geeks thinks it's feasible to achieve financial freedom with in a duration of time?
Regards.

Yes. I think achieving financial freedom within a certain time frame, is doable. You could talk to a financial planner, s/he could give you advice on savings plan/or retirement plan that suits your lifestyle.

But to become filthy rich, I think that has to be written in the stars? No? Luck and destiny play the biggest role in our lives, I think.
14 years ago
Hi Rob, Campbell,

Thank you. DeMorgan's law, eh? It's pretty challenging.

Btw, can you please explain the test condition again? The question says "Return the sum of the numbers in the array, except the number "13" and the 'number that come immediately' after a 13" (i.e. only one number that comes immediately after 13 is not counted, and the rest are counted, right?).

So, why do we use nums[i-1] instead of nums[i+1]?

Originally posted by Rob Prime:
You should also check out the previous element (as stated in the problem description):

Sorry for the trouble.

Thanks again.

Edit: Wait, I think I got it!

if nums[i] == 13

nums[i - 1] == 13 // ----> is the array element that comes AFTER a 13, right?
[ November 04, 2008: Message edited by: LS chin ]
14 years ago

Originally posted by Vivian Chu:
I fixed the statement error, I am still confused on how to declare my variables: aisfound, etc.

The 'true' or 'false' variable can only be boolean. Java keywords are also case sensitive. 'False' is not the same as 'false'.

Did you get your comparison operator "==" mixed up with your assignment operator "="?
14 years ago
Hi Campbell,

I tried your code and... nope, it doesn't work. Try putting your code in this link here and you'll see the answers to some of the arrays are correct and some aren't.

Originally posted by Campbell Ritchie:
You're welcome. Let's see if it will work in old-fashioned "structured programming."

Enjoy the puzzles.
14 years ago
Hi Campbell,

Thank you! You are right. Got to use 'continue' instead of 'break', and combined with the new test conditions, the code is now perfect.

Originally posted by Campbell Ritchie:
You shouldn't post that sort of thing when I am around because I am one of those people who believe you should only use break in a switch block. It ought to give the correct result with "continue," however.

Thank you!
[ November 03, 2008: Message edited by: LS chin ]
14 years ago
Hi Rob,
Thank you! The code works.

Originally posted by Rob Prime:
You should also check out the previous element (as stated in the problem description):

Please note that i > 0 check; without it the code fails if the first element is not 13.

Also, you shouldn't use break since that will abort the entire loop; any number afterwards is discarded.

I knew it had something to do with 'nums[i-1]' or 'nums[i+1] but I didn't know where to put it. :roll: Now, I see it~.

Thank you.
14 years ago
Hi all,

How to skip one element in an array and continue looping? For example, this question:

"Return the sum of the numbers in the array, returning 0 for an empty array. Except the number "13" is very unlucky, so it does not count and numbers that come immediately after a 13 also do not count".

sum13({1, 2, 13, 2, 1, 13}) → correct answer 4, but my answer is 3

sum13({13, 1, 2, 13, 2, 1, 13}) → correct answer 3, my answer is 0

Whether I use 'break' or 'continue', it does not work. How do I skip the number that comes after 13 and continue looping and adding to the sum?

All suggestions are appreciated. Thank you.
[ November 03, 2008: Message edited by: LS chin ]
14 years ago
Hi Dale,

Originally posted by dale truter:
haha, I tried but he uses such big words that I couldn't make heads or tails of what he was saying. 6 year olds, I tell you.

This is for your cousin, I hope he/she likes maths. It is not a full-proof program and has rooms for improvements but it's a start. Hope your cousin will enjoy it.

Enjoy!
14 years ago
Hi Gamini,

Originally posted by Gamini Sirisena:
I reckon that dale wants to present two numbers and an answer and the user has to guess what operator was used to arrive at the answer..

Oh? I thought, he wanted a randomly generated operator (creating a random math sign). No??

14 years ago

Originally posted by dale truter:
I have learned how to create randomly generated numbers but don't know how to make a randomly generated symbol.

I don't know if this is what you need but I think it should work.

Good luck.
14 years ago
Hi Ernest,

Originally posted by Ernest Friedman-Hill:
The servlet API was originally designed to be generic and independent of HTTP, so that it might be used in other contexts as well. Nevertheless, it turns out that nobody used it for anything else.

Oh, I see...

Thank you for the explanations!
14 years ago
Hi Bear,

Originally posted by Bear Bibeault:
In other words, "don't worry about it".

I can now progress to read the rest of the chapters without thinking of that 0.0001%!
14 years ago
There is also a very small errata in the code example on pg. 44.

This line doesn't compile because there is a " before the word text.
"<h1 style="text-align:center>"

This line compiles Ok.
"<h1 style=text-align:center>"

Is it correct?
14 years ago
Hi all,

This is a very newbie question.

In Head First's JSP and Servlet book (2nd edition on pg.44), it says, "99.9999% of all servlets are HttpServlets". I'm wondering, what is the other 0.0001%?

Is it a subtle joke which I didn't get, or is the 99.9999% actually true?