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.
I added more specification for that rule, Also glad to hear that some coders go to gym!
Definitely correct, see also my more detailed comment above, I only figured this out from garik's comment.
Including the lightest plate is fine (like your example here with 23kg) but the rules and description don't say anything about 2nd lightest etc.
Update: I figured out from garik322's comment below what is wanted and have now got passing code.
Rule 5 definitely doesn't make it clear that you want smallest, then second smallest, then 3rd smallest etc.
I'd suggest a rewrite of rule 5, and split into two rules
5. Solution should use the least number of weights
6. If multiple solutions with the least number of weights choose the one with the lightest weight included, if multiple with the lightest weight choose between them based on the second lightest weight, then third lightest and so on until one remains
Other than that, great kata, thanks! though you did earn me some funny looks at the gym this morning when i tried loading my bar up in this way haha
I think there is an error with some random test cases (in Javascript), ambiguous circumstances where it's not possible to decide between the solution expected and an alternative.
I'm getting this on 8 of the random tests, have broken out one example in detail below, with the others being similar. Apparently ambiguous with 2 correct answers.
Let me know if I've missed something here?
See the code below, I put in a console log for the target weight and weights available for reference.
Can't see how my answer is either better or worse than the expected answer given the rules
expected '--|42kg||18kg|------------|27kg||83kg|--' to deeply equal '--|52kg||18kg|------------|21kg||79kg|--'
Target >> 178
Weights >> [
'|79kg|', '|21kg|',
'|52kg|', '|50kg|',
'|124kg|', '|42kg|',
'|57kg|', '|79kg|',
'|83kg|', '|118kg|',
'|31kg|', '|18kg|',
'|43kg|', '|65kg|',
'|27kg|', '|21kg|',
'|113kg|'
]
Loved this kata, a fun hour of work, thanks!
.
Thanks!
I'll give it some thought and refactor ... just wanted to confirm it was possible before I bumped my head against the wall for nothing
Yes, the kata can be solved in JS, my solution takes ~4s to run all tests. This kata has performance requirements, you need a better approach than your current one. Your current idea is simply not efficient enough.
I've got a javascript solution that works perfectly for accuracy ... but times out on the largest test, can't seem to figure anyone way to make it run more quickly given the need for recursion and iteration.
Possibly because javascript is too slow when compared to C to actually calc for the huge array in sub 12 seconds - anyone actually made it work for JS recently?