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.
Sorry, I already delete or edit the comment, I'm new to this
Going by the instructions given, the result is incorrect.
I'm sure that is part of the reason this is only rated at 85%.
I've changed difference for distance to make it crystal clear.
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.
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.
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.
.
.
This isn't a problem about distance, it's a problem about integers and negative integers are very real.
-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.
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.
Should be fixed now, please inform me in case I missed anything
Fixed
[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.Please don't post solutions in Discourse.
Loading more items...