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.
I went down the same rabbit hole and I can tell you that optimizing calculations won't help you here. You have to find a sublinear method based on the triangle's properties.
Thanks for authoring such a great challenge! After a few days of working on this kata, a fun mix of mathematical and programming insight finally got me a rather efficient solution!
This comment is hidden because it contains spoiler information about the solution
Barely passed -> Time: 11866ms Passed: 4 Failed: 0
Kata was quite fun, had to add another condition in order to optimize it just under the 12000ms mark
darn, I thought I optimized it a lot but my code still times out, managed to solve 250 tests
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.
Too late to change the requirements...
Super fun to solve! I struggled a lot on finding the method to get to the numbers, maybe you should make it to 2 decimal points because we are dealing with money after all?
I rounded mine to the nearest thousandth, this way it automatically goes to the nearest second if its close enough.