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.
Great then 😉
I have completely the same solution!
You actually managed to make shorter version...
You have a list of 2 numbers: [0, abs(res)].
If the (res<0) returns True then the second item is taken. That is because True is the same as 1 in Python and the item with index 1 is abs(res).
If the (res<0) return False then the first item is taken (False = 0 in Python). So the item with index 0 is 0 in that case
This is O(log(n)) solution using binary search
omg, I also thought about dp but came up with simpler solution.
Nice one btw
You can console.log the input parameters, so that you can see what is being passed in.
approved
Your code will fail with nested loops. You need to find a more efficient way to compute the answer. Nobody should give you any formula, that would be giving the solution.
@RevelcoS do we need to add loop inside another loop? This solution doesn't work for numbers >10^6. May be one loop? In this case I can't create a solution
This can help: https://docs.codewars.com/training/troubleshooting/
This kata is not an easy 6 kyu. I advice you to practice on easier ones. If you don't manage to do one after some trials, move on, you'll solve it later maybe. You will progress and you will be able to solve harder and harder katas.
how to figure out what the problem is?
I am very new to codewars.
Most of the times, I pass the test but fail the attempt. How can I know what is the problem??
This kata can be solved without applying special formulas from Numberphile video. It is just for educational purposes. Try to come up with something "easier"
can you explain me please, what is the formula? If we don't need special even numbers handler, I have just
return Number.isInteger((num - 1) / 4);
and it's doesn't workEven numbers do not need special handling.
Loading more items...