Roller Coaster puzzle discussion

Hey peeps ! Trying to implement Tortoise and Hare Algorithm but get incorrect result for large datasets. Here’s my code:

[Mod edit: Please avoid posting codes on the forum.]

I did test it with all kinds of input data and it works but does one tests huge datasets anyways…

Not all kinds of input data apparently. Please read the previous discussion, and you’ll find these cases for checking the correctness of your code.

Also, please try to describe what your code does instead of posting codes on the forum in the future.

Thanks for the link @5DN1L. I have however did all kinds of testing with normal data and it works, as I have indicated in my previous post. Only when it starts to get to 10^9 problems arise.
I wanted to show my code in order for someone who has already solved the puzzle perhaps quickly pinpoint the problem. TBH I find it extremely inappropriate to not be able to post code at the coding forum. But it’s ok, I’ll post it on stackoverflow.

Your code doen’t always give the correct answers for the cases with small values in the link. You should try debugging from there.

@5DN1L, yes you were right I did have some errors with these specific tests. However after fixing them I still have wrong answer for the big data cases.

If you want, you may send me your code in private message and I’ll take a look.

This custom case may prove useful for debugging if you fail the last visible test (i.e. Test 6 “Works with a large dataset”) and the reason isn’t a timeout:


100 9 10

The output should be 724.