Many methods in Python take an iterable as their argument (this is usually noted in the signature description in the documentation). A generator expression is, much like a list, iterable. Therefore it is not necessary to actually construct a list (neither explicitly or via list comprehension), in fact it simply uses up more memory.
Yes, it does work without square brackets. I just checked, because I got identical solution except of square brackets I got list(). After removing list() it still works.
I think you misunderstood this: "The problem is not to understand the description but to find how to solve the kata.".
What I wanted to say is that it is not difficult to understand the description but once you understood, the question is how you will solve it. Last remark: you don't need to use floats.
"The problem is not to understand the description but to find how to solve the kata."
This is a rather abstruse and confounding line. Surely, if one has issues with the description, the far more difficult it is to solve the Kata?
I am also a native English speaker, and the description is very confusing indeed. The Math description with water weight to me, is unclear. For example, in your description you suggest a water loss of 1 percent accounts for 50 percent loss in overall weight. How does this follow if the water is 99% of the overall weight?
Despite this issue, which of course, could be my own personal confusion with it, the Math involved should be using Floating Point precision not integers. It will be quite a hack to get this working on Integers.
nah
that seems nice i would say it should be atleast 7kyu
That is very cool solution. I wish I guessed it
Many methods in Python take an iterable as their argument (this is usually noted in the signature description in the documentation). A generator expression is, much like a list, iterable. Therefore it is not necessary to actually construct a list (neither explicitly or via list comprehension), in fact it simply uses up more memory.
Yes, it does work without square brackets. I just checked, because I got identical solution except of square brackets I got
list()
. After removinglist()
it still works.very clever, like how the dict represents the two tests
also i didnt know you could assign a tuple as key
Nice - one of those solutions that makes you say, "Of course! Why didn't I think of that?"
This comment is hidden because it contains spoiler information about the solution
xrange: Somebody else previously fixed it.
getWeight: I've just fixed it.
To be honest the description isn't really needed; the test cases are enough. Just make the numbers work.
I think you misunderstood this: "The problem is not to understand the description but to find how to solve the kata.".
What I wanted to say is that it is not difficult to understand the description but once you understood, the question is how you will solve it. Last remark: you don't need to use floats.
"The problem is not to understand the description but to find how to solve the kata."
This is a rather abstruse and confounding line. Surely, if one has issues with the description, the far more difficult it is to solve the Kata?
I am also a native English speaker, and the description is very confusing indeed. The Math description with water weight to me, is unclear. For example, in your description you suggest a water loss of 1 percent accounts for 50 percent loss in overall weight. How does this follow if the water is 99% of the overall weight?
Despite this issue, which of course, could be my own personal confusion with it, the Math involved should be using Floating Point precision not integers. It will be quite a hack to get this working on Integers.
Fixed
Ok. Done, since you think it is better:-)
Sorry, I don't understand. I mean you should change:
"So much weight lost for so little water in less!"
to
"So much weight lost for such a small change in water content!"
Loading more items...