Programming Questions

  • Newest
  • Popular Tags
  • Ask A Question
  • Scale Balancing Test Cases
    So I got 2 incorrect test cases for the scale balancing question. For instance: When the input was ("[6, 2]", "[1, 10, 6, 5]") your output was incorrect. The output from my code is "6,10". I think that's correct. With these weights we get 12 on both left and right side. Now the assignment says there will only ever be 1 unique solution, which is clearly not the case here. Both "1,5" and "6,10" are solutions.
    marcel71 posted this question on 10/28/16 | scale, balancing
  • +
  • 1
  • -
  • The question required that you find "the least amount of weights", so a total weight of 6 (1+5) being less than 16 (6+10) makes 1,5 the only solution. Had there been a 2,3 solution, then there would have indeed been a duplicate "least amount of weights" solution
  • +
  • 0
  • -
  • I think though that the wording is needlessly ambiguous: instead of saying "the least amount of weights", which can be read as preferring one weight to two weights, no matter how heavy the single weight is, and not giving any preference between sets of two weights, it would be better to say "the least total weight", which would make it clear that sets of weights, including single weights, should be ordered by the total, so that 1,5 would be an unambiguously better solution than 6,10.
    Log in to write an answer.