This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!

Liutauras Vilda

Marshal
+ Follow
since Nov 12, 2014
Liutauras likes ...
BSD Linux Mac OS X VI Editor
London, United Kingdom
Cows and Likes
Cows
Total received
464
In last 30 days
21
Total given
1481
Likes
Total received
1399
Received in last 30 days
12
Total given
1390
Given in last 30 days
22
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Liutauras Vilda

Mine was Sony Ericsson T10, however, it wasn't the most fascinating thing to me, more joyful experience was how I got it. Short story below.

I was born in a small town called Joniskis, at that time its population was about 15_000 people. Very few computers were across the town. And I was the guy who knew how to use keyboard fast, no more than 5 of us were like that in those days. And so our services were very popular among the students who had to lay down their dissertations on word documents to be ready printed out, we used to charge 2 Litai per page, so if the dissertation were around 170 pages, I used to get 340. So this is how I saved some money and bought this phone, it was second hand, for ~150 Litai, that was around 2000.
3 days ago
Ah, you mentioned about beginIndex in case of one argument supplied. Ok, it could be confusing. Question for OCAJP?
6 days ago

Dave Tolls wrote:If that was in response to me, then my question still stands.
Why does "hello".substring(5) return an empty string, and "hello".substring(6) an IndexOutOfBounds?

To me it's counter-intuitive.  5 is as much "out of bounds" as 6...


Well, in which case:
"hello".substring(0, 5) also supposed to throw an out of bounds, but it doesn't, it returns hello.

I think it is sort of consistent here.
6 days ago
If such an exercise is for the cs's course exam, during the stressful time it can get annoying very quickly tracking information floating around if you don't write values on a piece of paper..
1 week ago

Dave Tolls wrote:I'm not convinced I've written that as clearly as I intended!


I can assure you, not worse than I would have been.
1 week ago

Suane Mane wrote:In order to find the remainder you need to divide. So you are dividing even if the result required isn't the result of the division. 3%2 would have a remainder 1, yes.


In which case you'd get 1.5, and not 1, same as in your initial logic.

I think Dave gave an info, that the division is based on how many whole numbers fit. 3 % 2 as in this case, how many 2's fit to 3, so you divide 3 / 2, you get 1 and remainder 1, so you are correct on that one. And now if you get back to your initial example 1 % 2, how many 2's fit to 1? 0. You don't take fractions.
1 week ago

Suane Mane wrote:In mathematical logic it should not. 1 divided by 2 is 0.5.


But you are not dividing, you use modulus operation in actual question.

What would be 3 % 2 according to you?
1 week ago
I think worth mentioning this topic of our colleagues, it is fairly long, but gives a pretty good information. Some of the aspects I found really worrying in the mentioned project.
1 week ago

Liutauras Vilda wrote:

wayne brandon wrote:while (userSelecting)


What do you think, would that work better? "while user did not press to exit system"

Other than that, please explain, how would you tell your program what is that "while user selecting"?


I might take back this my comment. Now thinking that maybe not a bad idea to invert that phrase and use as OP suggested by hiding details how user finished selection.
1 week ago

wayne brandon wrote:while (userSelecting)


What do you think, would that work better? "while user did not press to exit system"

Other than that, please explain, how would you tell your program what is that "while user selecting"?
1 week ago

Emilie de Rochefort wrote:I wanted to use the Runtime.getRuntime().halt(0); command to stop the loop after the user guessed the correct number.


That is sort of abnormal way of stopping something when the condition has met.

Think if you could have something similar to:

You also would need to think how to enter loop.
2 weeks ago

Tim Cooke wrote:I have only come across this recently and my initial reaction is that I don't like it.


I've been encouraged in the past to use that magic myself, however, same as you - didn't like it at all and didn't use it. You can't validate parameters for setters, if you do want to validate them, you go back to a habitual Java's way, in which case you end up with hybrid code, which is dreadfully difficult to follow. If I'm lazy, I let IDE to generate stuff.
2 weeks ago

John Losty wrote:I don't understand what he has done.
He didn't said what was applied and how, he just added this line


Read the replies carefully until all click. Stephan's showed example with hypothetical parentheses helps to re-assemble the case what is really happening behind the hood.

I'll try to repeat same stuff just in different words.

As been said by all, expressions are being evaluated from left to right. What that actually means is, each value evaluate as if there were no other values on the right, in other words, ignore them until you really need them. What I'm saying might technically isn't very accurate, but...

int a = 2;
int b = 5;
int c = a * (a++ - --b) * a * b;


1. So, initial value of 'a' is 2. So what you have is (remember, ignore the most right part from the point where you are looking at this very moment):
int c = 2 *

2. Now, in the parentheses you have a++, which means: "place the current value of 'a' in the expression and only then increment. So you have:
int c = 2 * (2
remember, after all this done, 'a' gets increment to 3.

3. So next is with b. Current value of 'b' is 5, and --b means, first decrement current b's value and only then place it into expression, so you end up with:
int c = 2 * (2 - 4)

4. Let's continue. Remember, from the step 2 you increment 'a' to 3, so now a is 3. What we have next is:
int c = 2 * (2 - 4) * 3

5. This one is similar to above, 'b' value following the step 3 ended up being 4, so:
int c = 2 * (2 - 4) * 3 * 4

So you have all unknowns revealed now. Again, looking from left to right, you do the arithmetics. Note: to a parentheses look as to a grouping, so basically they mean which operands get calculated together (formulation of mine here is perhaps wrong...).

int c = 2 * (-2) * 3 * 4
int c = -4 * 3 * 4
int c = -12 * 4
int c = -48


So if I didn't mess up anything along the way, answer would be that. Which I didn't, because Stephan also got that.
2 weeks ago
When not much free-time left, sounds like a good plan to go to time's debt. Will have to check this exercism.io.

For now just registering to watch this thread to get updates from your talks.