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.
Lovely!
Genralized tip:
You'll fail all the test, but usually you'll see the input. (Except, as you'll discover here, not always.)
Often this will help you find out the count of tests. (Although, again not always.)
I was able to reach 65 tests, but still timed out. I suspect we're using the same algorithm (but I've optimized mine as much as possible). I have in mind another algorithm which I think may be faster, but don't have time to implement it at the moment. I'd encourage you to try a different approach. 232 people have solved it in Python, so it should be doable.
No spoilers, sorry. :)
Looks great.
I think that's a lot clearer. It makes it clear that elements can't be re-used but that values may appear more than once.
Alternatively, you could have the output be a value:multiplicity mapping which might be more readable than a list of indices and is easy to check.
I don't know if it is needed to change the kata in order to fix the description, but if that is the new requirement of the kata:
I think this uses clear terminology, but also restates the definition in a way that (I hope) avoids potential confusion.
That'd certainly be clearer, and even if someone is led astray by it (since it isn't a strict requirement), they can still arrive at a solution.
While that is a fair point, I don't think it addreses my criticism. The kata being named after its source problem in mathematics makes sense, but my criticism is about clarity. 'Set' has meaning in both domains and we should use it carefully and explicitly. Additionally, solutions to the SSP are often actual sets (indices or pairs of (value, multiplicity)) rather than multisets. I think even linking to the wiki page or using the word 'multiset' would help clarity tremendously.
Edit: I was writing my reply to @Mednoob concurrent with yours, @JohanWitlink. It was not meant as a response to you.
The kata title and description are unclear. It is called "Subset Sum", but the input is a list and the output requires a list. We are looking for a sublist sum of a list and "sublist sum" may be a better title.
The kata description reads:
I think this should be rephrased. I understand that it is getting at the difference between elements and values, saying you can use values multiple times iff there are multiple elements with those values, and that any element can only be used once. However, it took quite a bit of mental parsing to understand (which was further confused by the title).
Edit: I realize that 'sublist' may also be unclear here, because it may be interpretted as 'contiguous sublist'; so I'm not quite certain what I would call it, so 'subset' may be more appropriate, thinking of it as a subset of elements, rather than values. But if so that distinction of elements and values should probably be more prominant.
This comment is hidden because it contains spoiler information about the solution
I don't know why this was downvoted. The description doesn't say anything about per-test time limits nor is it specified anywhere what these limits should be. This information should be in the description.
Why it matters: Knowing whether your code is a few milliseconds off or an order of magnitude off affects your approach on solving the problem. Imagine if the time requirement was 240 microseconds. Then the solution might just be to modify a conditional or include a called function's code directly in your main function. Now imagine if the time requirement was 10 microseconds: You'd be pretty sure your entire approach should be questioned.
For anyone looking for what time they need to get it to pass, the slowest run of my passing solution was around 90 ms for the batch. Guessing the cut-off is 100?
The input should be specified. Mention it's structure, and also define what is meant by 0, 1, and 2.
For anyone confused by this, read the comments that are pre-loaded in the solution box (where you write your code).
I realize these comments are quite old, but @DworkinFromChaos is right.
Specifications don't belong in the (mutable!) fields of the kata. They should be in the description, perhaps especially in the case where they cause otherwise working solutions to fail.
Isn't @paraliterary's point that the field is invalid but your solution returns
True
indicating that it is valid?Loading more items...