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 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
This comment is hidden because it contains spoiler information about the solution
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.
This comment is hidden because it contains spoiler information about the solution
I used C++, my code passes the actual tests just fine though.
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.
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
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.
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?
Not the best solution, but it made my day.