Ad
  • Custom User Avatar

    I had the same error. They should have specified that the condition is can he live until the beginning of year N, and not the end, therefore you only calculate n-1 times

  • Custom User Avatar

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

  • Custom User Avatar

    I'm not sure it's an integer overflow, sometimes it calculates slightly over or under. Changed the calculation to use

    In this specific order: sum=n*(n+1)/2n(n+1)/2

    Somehow it has to be like this or it wont calculate properly.

  • Custom User Avatar

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

  • Custom User Avatar

    I used C++, my code passes the actual tests just fine though.

  • Custom User Avatar

    I made a similar algorithm to yours and got the same error. The problem was that when I modulo 101^exp, I got the result of 1, which was used as the exponent for the next number.

    This problem happens whenever base^exp ends with .....0x. So modulo cuts the number to the ending digit x, which makes the next steps for that case into 2^(2^1)=2^2-1. Whereas 2^(2^101)=2^(long number which ends with....52) = long number which ends with 6.

    Try changing the algorithm to do something slightly different for these cases.

  • Custom User Avatar

    There seem to be a sample test which I'm consistently failing.
    Case 1: 83 6 2 ---> Expected: 9 Actual: 1
    83^(6^2) = 83^36
    I used a calculator 3^36 = 150094635296999121

    I've already passed the Kata

  • Custom User Avatar

    Hello, I tested my code for n=50 on codewars and on my machine. Codewars got the answer in 2203 ms and my machine 291 s. It kind of brute forces its way through partition generation, so I expected it to take a while. It's good news that it didn't time out, but does that make my computer a potato?

    For confirmation, both codewars and my machine returned range=86093441 when n=50. Spent some good hours on this and had a great time.

  • Custom User Avatar

    Wow that was very hard. Is it possible for an int or vector return value to be accepted? Can someone explain why it needs to be string?

  • Custom User Avatar

    Not the best solution, but it made my day.