Ad
  • Custom User Avatar

    I think std::floor(result * 1000000) / 1000000; should work fine. You might want to look at the result before truncating, because 1146652 is rouned up.

  • Custom User Avatar

    Thank you! All the tests passed successfully. I too, am all for a BigInteger library. It will benefit many katas similar to this one.

  • Custom User Avatar

    It seems that an overflow occurs before the test... I lowered n and p in the random tests. Could you try again? Hopefully it will work. It would be better if we had a BigInteger library at Codewars! I upvote your last post:-)

  • Custom User Avatar

    I still believe there is overflow occurring before the check against ULLONG_MAX - 1000. For example, diagonal(183, 19) must be greater than diagonal(80, 19) but the random tests expect values of 401227812924226601 and 762367057337870191 respectively.

    My code passes many of the smaller value random tests such as diagonal(77, 16), so I assume my approach is not completely unreasonable.

  • Custom User Avatar

    I understand now. For diagonal(183, 19) solutions return 401227812924226601. All solutions of random tests are less than ULLONG_MAX - 1000.

  • Custom User Avatar

    Oh, by writing 2.79e+26 I don't imply that that's the return type. It is just easier to compare the numbers this way instead writing 278635918444896000000000000 and 401227812924226601 in the comment(with some precision lost).

    My code returns unsigned long long, but the result of some of the random tests doesn't fit in 64 bits.

  • Custom User Avatar

    I am very sorry but maybe you should look again at your code. The return is an unsigned long long not a float number. It is not an issue of the kata but of your code.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution