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.
There might, if I knew the language I might fix it.
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.
This comment is hidden because it contains spoiler information about the solution
you are absolutely right. Thanks, man!
The
true : false
bit at the end is unnessary. The&&
will return the result you need.Kata are better when they are about the 'what' rather than the 'how'
assert_equals(swap([a,b]),[b,a]))
would be reasonable and easy to test.The extra constraint you have here about not using a temporary variable, perhaps make for a nice puzzle, but not so good for a kata.
A technique that some kata use for testing the method used is to apply some space or time limits.
Most often used to test for algorithmic efficiency by testing against large data sets and using the execution time limit as a pseudo test.
In this case you might want to somehow invoke a space limit by having a and b both being gigabytes in size so that the VM running the test has no room left to allocate space for the temporary variable, but since it would end up just being a tiny reference, that's probably not going to work.
Hi there!
So I changed the description, no need to store the variables in an array, just return them
and added some more tests but the kata will still pass if a temporary variable is introduced.
Do you have any pointers on how to test that?
Thanks for your help, feel like this is getting closer to what I originally wanted to
publish!
Yes, this is my first one and I am definitely seeing that!
Will try to refactor it today and add more tests that specifically check that
the values the variables are pointing at have actually been changed rather
than just changing the order :)
Great!
I'll check back a bit later to see how you're getting on.
It sometimes takes a while to craft a good kata.
The description talks about swapping but there is no swapping involved.
The description says not to use a tempoaray placeholder, but there is no test for this condition.
There is no test that the values of the variables are changed after running the function.
Why is there an array being returned? What's that got to do with swapping?
Yes, working on it! I'm also changing the description a bit to make sure that the goal of the kata is understood.
Needs more tests.
haha, I guess you know how much I need to refresh my maths knowledge, thanks :)
4⁰ == 1
.This comment is hidden because it contains spoiler information about the solution
Loading more items...