Win a copy of Python Continuous Integration and Delivery this week in the Python 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
443
In last 30 days
2
Total given
1446
Likes
Total received
1369
Received in last 30 days
20
Total given
1347
Given in last 30 days
49
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt Green check

Recent posts by Liutauras Vilda

Steven Fraser wrote:Liutauras Vilda,
Which would lead me to ask; when writing programs, how descriptive do we want to be? Should be?


I think Junilu answered that way better than I could have. After all, he's one of those who made one of the biggest impacts for my career. As you see, I've made a remark about his refactored version, and all that lead even further, so even better version been suggested (read further for more). So if you think whether ask something or not - ask, remark, always - it pays back.

Junilu Lacar wrote:The name extraBoxAsPerNeed does not appeal to me as much and the distinction it has over boxForExtra isn't that much. However, I might experiment for a minute with similar names with like intent such as boxForAnyExtra(candybars). My goal is to make the code read like a casual conversation, which I find much more pleasing. "Plus an extra box as per need for candy bars" just isn't consistent with the way I talk in real life.


Again, I'm glad I joined the conversation. We always talk about the "better name", and sometimes indeed is hard to distinct what is better (apart from obvious). "...isn't consistent with the way I talk in real life" - I found this as a very good metric to consider. While I myself fine with my suggested version, I must admit I like yours boxForAnyExtra(candybars) way more. In the subsequent post suggested names also great.

So I think if the lately suggested method name(s) didn't make anyone feel worse about them, while at least one (myself) person found such method name boxForAnyExtra(candybars) more readable, I think that qualifies as - "more readable code" as odds increased.

16 hours ago

Junilu Lacar wrote:


I like very much everything else in your refactored version and how you approached it, apart from the boxForExtra(candyBars). In particular its name. This name somehow indirectly implies in my mind two things: [1] there are extras [2] there will be a guaranteed box. Looking to its implementation all doubts get cleared though.

Currently my mind would understand it better if method would read as:

So from this method name, I personally can better understand that might be needed an extra box or might not without looking to its implementation.

But maybe it just now I feel that way.
19 hours ago
Also, why do you add those extra parentheses eaten.split((","))? Maybe that is part of an issue. After you split string, try to print its length on the following line and see what you get. Also try to print the content of meal array, and see whether it is something what you expect.
1 day ago

M. Gumblert wrote:kcal_limit = kcal_limit - int(meal[1])
IndexError: list index out of range


Please tell, what input you have entered as for meal?
1 day ago
Hi M. Gumblert,

Let's start from the beginning.

What would happen if one would enter weight of 110 kg? (pretty much mine).
1 day ago
Steven, formatting and indentation of the code is exemplary. Well done on that!
1 day ago
Moritz Lenz, welcome to the Ranch again Have a great week answering questions.
2 days ago

Tom Joe wrote:Unfortunately, there are no tutorial ratings and there are no...courses on pluralsight


That's not true from what I see.
Because you simulate recursion. From the drinksMenu() you don't need to call mainMenu(), it would return to it after drinksMenu() exits its body. Remove a mainMenu() call from drinksMenu() and see how your program behaves then.
2 days ago

Nathan Milota wrote:

Campbell Ritchie wrote:Yes, I think that would be a working solution; somebody else has already suggested it.




I didn't read it.  I was just making sure I understood it myself.  The problem wasn't my lack of skills then.  It was just not understanding what the problem was asking.  

The word driver threw me off, because I was thinking installing drivers on your computer.  


The thing is, that problems usually are not being described in step-by-step algorithm. That is a goal - to come up with one.

When you get problems described in real life, they sound pretty much like that. Most important in my opinion is - is to ask questions when you are in doubt and not assume something, what may or may not be correct.

If somebody would have said to you, find an index of a given array, from which summing up the numbers to the left of the given index and to the right of the given index those sums would be equal - that is an actual algorithm. I trust only 1 out of more (than one).


So it didn't make any clearer for you when I described to you how I perceive these instructions. But that is normal perhaps as different people perceive explanations differently, and possibly only different phrases make "aha" moment to certain individuals - that is the main reason why many of us here explain same things over and over again just in different words, so each of us could absorb what fits them better.
2 days ago

Nathan Milota wrote:I have to ask, is this a typical Java interview question?  If so, I'm way off from being ready for the first interview, because I don't even know what this question is asking.


Nathan, my Dad once said to me (when I was struggling with math homework exercise for primary school), if you don't understand what is being asked, read it through 100 of times until you do understand.

You can minimze that number significantly if you take apart all what is being asked and start sketching out.

Instructions wrote:[1]You are given an array on integers n length n for a driver. [2]The integer at index i symbolizes the time allocated to her or his i'th task in minutes. [3]The optimal time for a break s between two tasks i and i+1, [4]when the sum of all tasks from 0 to i equals the sum i+1 to n .

[5]Write a method that returns index i where the condition above is met. If there is no such index the driver is not awarded a break and the method returns null.


[1] So it says, that you (as a developer) are given an array of numbers (n length means - you don't know how many of them, could be 1 or 2 or 3 or 4 or more), for example [1, 4, 1, 3, 1], and those numbers denote the task times for some hyphothetical driver. Imagine maybe a taxi driver.

[2] [1, 4, 1, 3, 1] <-- so each individual integer (type of number, a whole number, without the fraction) represents a task time in minutes. So first task takes 1 minute to do. Second task takes 4 minutes to do, third task takes 2 minute to do, and so on.

[3] So here it talks about optimal time for break between the tasks lets say second and third, example: [1, 4, <break> 1, 3, 1]

[4] And what is really meant here, that optimal time for a break is, when you have finished some tasks, and those tasks took half of the time of all tasks time. Or in different words let's say you finished tasks which took 4 minutes and you still got other tasks to do which also will take 4 minutes to do. Sort of in a half way through. Example [1, 4, <tasks on the left 5 minutes = tasks on the right also 5 minutes> 1, 3, 1]

Is it clearer?
3 days ago
C Robinson, wanted to point out one thing, the way you described your problem and explained what issues you ran into - it was exemplary.

Being able to describe clearly a scenario which you attempted, what have you tried already, what went wrong, and what did you expect actually is a good indication that you are heading correct way as a programmer - that's an important skill.

We all do such mistakes which sometimes is very hard to find, so yours was one of those.

Actually one more thing. Please also pay the same attention to the comments you write in your code. As they are - they are pretty useless, because they don't tell anything useful or anything what we couldn't acquire from the code already. And I think if you were not have those written, you might would have spot that unnecessary semi-colon yourself, because your eyes wouldn't be hooked by the comment which is in the following line.
5 days ago
At line 19 you got semicolon at the end of loop declaration, so that finishes statement and "month" variable goes out of scope, remove that one as that is a mistake to do.
5 days ago
Maybe your computer technical resources aren't enough to run it? By the the way, do you use plain Eclipse with bunch of plugins or actual Spring Tool Suite whose base is Eclipse?

However, if there are specific problems with Eclipse on your machine, you can try other IDE(s) as IntelliJ, NetBeans. For example many say that IntelliJ work for them slower than Eclipse, my personal experience is opposite. Eclipse for me feels way more sluggish on my machine than IntelliJ.
5 days ago

Keep in mind that the user that is running your program needs to have access to the C: root this way.


In addition to what Rob said, there would be also a limitation on what OS your program may run. Windows presumably. Other operating systems may have different file system structure, so the organization of it would look different.
6 days ago