Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
noice
Now I get it. Thank you!
You have a misunderstanding of something.
n
is a number.str(n)
turns it into a string.strip
just removes the leading and trailing characters. All of this 'launches' in both cases. Theint
throws an error if it receives an empty string, which is the case if input is only zeros, since you strip them.This comment is hidden because it contains spoiler information about the solution
It doesn't skip anything. Python's
or
statement returns the left side if it is true and with strings that is whenever the string is not empty. Only when the left side is false does it proceed to evaluate the right side and it returns it regardless of is it true or false.This comment is hidden because it contains spoiler information about the solution
Your decision is impressive. Understanding complex numbers is something I need to work on.
For this, it would be possible to implement the girlfriend's task .. For example, 2.4.5.7.8
This comment is hidden because it contains spoiler information about the solution
The primary tests in python test for gracefulTipping, yet the remaing tests use graceful_tipping. Please fix.
Add a fixed test with
bill = 50/1.15
.I had a student wrongly solve the task but all the tests passed.
I hadn't actually checked for the problem at hand but about the general concept of using sum() vs len(list()) a while back.
My argument about the early exit was malformed. It's not about memory but rather performance. And it's not an argument for my approach but against using 'sum'. So the best thing would be to have a 'for' loop over 'PATTERN.finditer' and a 'continue'.
Anyway, thanks for the reply. Apologies for not using backticks, don't have them on the phone keyboard.
Cheers
But did you actually check?
I updated the fork and as you can see, there isn't any meaningful difference in performances between the two, here. So the iterator performs the same without allocating the full list.
about "more readable", question of habits, I'd say
about early exit, well. Might be true, but not even sure (since python is interpreted and balbla, so builtins are faster than user made early exit codes, very often).
Anyway. Considering the size of the problem here, both will do for sure.
Honestly, after giving it a little thought, the memory allocation is not a bad idea in this case or rather in any cases I worked with regexes. While streams are more efficient in memory they underperform in speed (in python at least). And the memory we'd be allocating is rather unsignificant. And I'd argue the len approach is more readable or rather closer to the spoken language.
On the side note, if you care about memory wouldn't you stop counting matches after you reach 5 in the first line of the haiku, that is 7 in the second line?
Why finditer? :)
EDIT: didn't see you can put description, thanks, got my answer!
Loading more items...