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.
This comment is hidden because it contains spoiler information about the solution
This is almost too easy. It works though, nice.
I solved it with using regexp
Not a suggestion.
This comment is hidden because it contains spoiler information about the solution
this problem is painful
This comment is hidden because it contains spoiler information about the solution
What about the case the person buys 3n-1 mangoes and get 1 mango free?
Iterating one time is orthogonal to using exceptions for control flow, so it doesn't really answer the question. I think using exceptions for control flow is considered less evil in Python than in other languages, although it's still questionable. But best practices votes here are so random that no one knows if it's best practices at all )
yes, this way you traverse the list only one single time
This comment is hidden because it contains spoiler information about the solution
Duplicate of https://www.codewars.com/kata/54492291ec342c4a440008c5.
Can you please be more careful when approving a kata next time? This kata has several issues and design flaws.
Also this is an issue.
What about
k < 0
? If you're testingk > arr.length
, I don't see why this is not included.The case
arr === null
is not tested.(It's also a kinda pointless input validation, so I'd suggest dropping it completely.)
Loading more items...