Ad
  • Custom User Avatar

    Sorry, I already delete or edit the comment, I'm new to this

  • Default User Avatar

    Going by the instructions given, the result is incorrect.

    I'm sure that is part of the reason this is only rated at 85%.

  • Custom User Avatar

    I've changed difference for distance to make it crystal clear.

  • Custom User Avatar

    Difference means: the result of subtracting one number from another. How much one number differs from another. From the title "Compare with Margin", the difference is going to be a positive number since you are comparing the the difference between the 2 numbers given and the margin. Say on the number line you have a point at -5 and another point at 6 and you are trying to see if the margin between the 2 numbers is less than 12. You would not say because -5 -6 = -11 and -11 is less than 12, you would get the absolute value of -5 - 6 and compare the two. It doesn't need to be explicitly written in the directions.

  • Default User Avatar

    The instructions don't say either a-b or b-a, they say very clearly a-b. They don't mention the difference having to be a positive number.

    in my example:

    a-b = (-1272 - 7169) = -8441. Does it not?
    -8441 is less than the given margin (1339). Is it not?

    According to the instructions given, these params would return 0.

  • Custom User Avatar

    Do you know what margin means? When you measure something, and it's not an exact measure, the number is noted as X ± Y where Y is the margin or tolerance. With a difference of 8411 (or -8411) and a margin of 1339, does that sound "close" to you? Close -> distance.

  • Default User Avatar
  • Default User Avatar
  • Default User Avatar

    This isn't a problem about distance, it's a problem about integers and negative integers are very real.

  • Custom User Avatar

    When a is lower than b, return -1.

    -1272 < 7169, right? The difference between a and b is always positive (think about it like a distance, there is no negative distance). So if b > a you should compute b - a instead of a - b or always take the absolute value of a - b, your choice.

  • Default User Avatar

    The tests are setup wrong for this problem. For example:
    a = -1272
    b = 7169
    margin = 1339

    Difference between a & b = -8441

    1339 > -8441 therefore according to the instructions (if the margin is higher or = to the difference, return 0), this should return 0 but the passing result is -1.

  • Custom User Avatar

    Should be fixed now, please inform me in case I missed anything

  • Custom User Avatar
  • Custom User Avatar

    [Java] Initial solution does not compile, even after adding return 0 in the method body. Perhaps the method signature is wrong?

    For an 8 kyu Kata not focused on debugging, the initial solution should compile; hence this is an Issue.

  • Custom User Avatar

    Please don't post solutions in Discourse.

  • Loading more items...