4 kyu
Gymbro's Unique Gym - Weight Calculator
25 of 33Zanamo
Loading description...
Algorithms
Performance
Combinatorics
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
python new test frameworks
This comment has been hidden.
All existing Python solutions except author solution is invalidated. Is the kata even solvable at this moment?
I decreased the number of test cases for both languages, even though the task was easily completable
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|' ]
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 added more specification for that rule, Also glad to hear that some coders go to gym!
This comment has been hidden.
This comment has been hidden.
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.
Hi,
The description is missing the typical specs of the tests: number of plates per test, number of tests
Cheers
Author already answered somewhere below that "small/medium/big" should be enough, but I agree with B4B, on a "performance" kata, you need to specify more detailed test and input constraints.
This comment has been hidden.
well, small/medium/big are meaningless because they are entirely different things, depending on the time complexity involved. So, yeah, it definitely should be added to the description ;)
This comment has been hidden.
I hope you put the simpler random tests before the heavy ones...? (they are inverted in the desciprtion, right now)
This comment has been hidden.
yeah heavy weight, does not mean "heavy" test
algorithms
This comment has been hidden.
assert.deepEqual takes a third parameter, you can make a nicely formatted string with input params and exptected and actual string formatted in it if you want.
This comment has been hidden.
It turned out to be a challenging and fun kata, well done!
This comment has been hidden.
In JS, on error: also log the input parameters, not just the actual and expected result.
This comment has been hidden.
This comment has been hidden.
ah interesting! lemme check my solution for these cases
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
You really "solve" issues way too soon. This still isn't fixed.
Here's another error in ref sol:
This comment has been hidden.
Are you sure it's cool?
Ok, it took some time for CW to refresh. It is COOL now.
You need more variation in random tests. There should be a bunch of tests with low target weight (between 10 - 20 kg) with many small weights, preferably weights between 1 and 3 kg, with most weights below 2.5 kg. This should invalidate solutions that incorrectly bail out on the wrong condition.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
What are the rules here? My solution has lowest weight on both left and right bar. Your solution only on left side. Tie breaker is not defined in description.
Here's another one where the ref sol doesn't even find the solution with lowest weight. This is actually another issue as above.
so you still haven't explained which bar to take when both possible bars have the lowest weight:
This comment has been hidden.
This doesn't make any sense to me. Don't put "balanced" in the description if imbalance only builds up on a single side.
Proper balancing would be
Nevermind, the description mentions a distribution, not a balanced distribution. It's still a bit odd, compared to how weights would normally be placed on a bar, but ok.
This comment has been hidden.
6 plate configuration seems to be tested but not actually tested: see this solution
This comment has been hidden.
This comment has been hidden.
Still missing the edge case where the only possible configurations don't fit on the bar.
Added them too.
This comment has been hidden.
This definitely isn't right.
This comment has been hidden.
What definition of "cross middle point of the bar" are you using? Because this definitely isn't what a typical person would mean by that; the two sides match perfectly at the middle. So if anything the kata description is being unclear again.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
There is apparently performance requirements for the kata (brute-forcing all possibilities will time out), so there should be a
performance
tag, and input size should be specified.This comment has been hidden.
No, we need actual numbers. What is the maximum array length?
This comment has been hidden.
Reference solution incorrectly calculates the weight when 3-digit plates are involved:
This comment has been hidden.
Reference solution is not following the specifications:
'--|41kg|------------------------|49kg|--' should equal '--|42kg|------------------------|48kg|--'
It's also still ambiguous in cases with multiple solutions, each of which uses the least heavy plate:
'--|40kg||33kg|------------|39kg||53kg|--' should equal '--|44kg||33kg|------------|39kg||49kg|--'
Did the author check only the first plate?
This comment has been hidden.
This issue isn't fixed, at least not in JS. EDIT: it has now.
It is unspecified what "desired weight" means, and how
w
is relevant to the task.This comment has been hidden.
This comment has been hidden.
So, is it the minimal weight exceeding the desired weight, or the maximal weight below the desired weight? Is the desired weight inclusive?
There can be multiple correct solutions but you only accept one. For example in the sample tests:
'--|7kg|--------------------|2kg||19kg|--' should equal '--|10kg||3kg|--------------|7kg||11kg|--'
, and'--|126kg||122kg|--------|123kg||134kg|--' should equal '--|211kg|----------------------|287kg|--'
.Either specify a total ordering for answers and make the user return the best answer according to the ordering, or make the tests allow all correct answers.
Also, it seems like you only want to accept an equal number of weights on either side but this is not written anywhere in the description. For example, getting these in the random tests:
'--|13kg|------------------|11kg||20kg|--' should equal ':('
, and'--------------------------------|13kg|--' should equal ':('
.In the description, you say "with the heaviest Weight on the left!!!", but both the description and tests expect the heaviest on the right.
This comment has been hidden.
This comment has been hidden.