4 kyu

Gymbro's Unique Gym - Weight Calculator

25 of 33Zanamo
Description
Loading description...
Algorithms
Performance
Combinatorics
  • Please sign in or sign up to leave a comment.
  • saudiGuy Avatar

    This comment has been hidden.

  • Voile Avatar

    All existing Python solutions except author solution is invalidated. Is the kata even solvable at this moment?

  • caffreydev Avatar

    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

    1. Equal amount of plates each side: yes for both
    2. 2 hyphen gap from end: yes in both
    3. Each plate avilable once: yes used only one
    4. Weight dist matters... : yes heaviest on right then left etc.
    5. If multiple solutions choose the one with least number of plates and the least heavy plate: my solution and expected both include the lightest weight (18kg), and both have the least number of plates (4).
    6. plates shouldn't cross middle: yes, neither crosses middle.

    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|' ]

  • garik322 Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    Hi,

    The description is missing the typical specs of the tests: number of plates per test, number of tests

    Cheers

  • dfhwze Avatar
    • You have many tests with big weights. I suggest you add a couple of small weights ( <= 3kg ) in those test cases from time to time. This makes the cases more challenging in certain situations.
    • Given the current performance constraints, I would adjust the estimated rank on this kata. This definately is a blue kata.
    • suggested tag: algorithms
  • dfhwze Avatar

    In JS, on error: also log the input parameters, not just the actual and expected result.

  • dfhwze Avatar

    This comment has been hidden.

  • dfhwze Avatar

    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.

  • dfhwze Avatar

    This comment has been hidden.

  • dfhwze Avatar

    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.

      goal -> 80,
      weights -> [
        '|9kg|',  '|26kg|',
        '|6kg|',  '|13kg|',
        '|6kg|',  '|7kg|',
        '|25kg|', '|14kg|',
        '|27kg|', '|7kg|',
        '|12kg|', '|16kg|'
      ]
    expected           '--|14kg||12kg||6kg|--|6kg||13kg||26kg|--'
    to deeply equal    '--|14kg||12kg||6kg|--|7kg||13kg||25kg|--'
    
  • dfhwze Avatar

    This doesn't make any sense to me. Don't put "balanced" in the description if imbalance only builds up on a single side.

    --|30kg||5kg|--------------|7kg||34kg|--
    

    Proper balancing would be

    --|30kg||7kg|--------------|5kg||34kg|--
    
  • Voile Avatar

    6 plate configuration seems to be tested but not actually tested: see this solution

  • Voile Avatar

    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.

  • Voile Avatar

    Reference solution incorrectly calculates the weight when 3-digit plates are involved:

    w = 250
    '--|101kg|----------------------|136kg|--' should equal '--|100kg|----------------------|136kg|--'
    
    w = 279
    '--|100kg|----------------------|166kg|--' should equal '--|99kg|-----------------------|166kg|--'
    
  • scarecrw Avatar

    Reference solution is not following the specifications:

    if there are multiple solutions, output the one which requires the least amount of plates, and which has the least heavy plate

    '--|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|--'

  • Voile Avatar

    The challenge is to help Gymbro calculate and put the desired weight on the bar using the available plates while following specific rules.

    It is unspecified what "desired weight" means, and how w is relevant to the task.

  • Avanta Avatar
    • 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.