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 are already fixed tests with negative numbers, your solution will also return
false
(which is correct) forn = -5
/n = -6
because whenx = 2
,-6 != 2 * 3
for both cases above.no random tests in Clojure and Ruby
I was not able to replicate the problem, the reference solution returns
false
for72
and other non-powers multiples of4
such as20
,44
, etc. Nevertheless, I added those as fixed tests and upgraded the C# random tests to improve coverage. This kata still has a poor design in C# due to the parameter being anobject
and the input validation, which is already not a good idea, is underspecified and not toroughly tested.Thanks!
duplicate of this issue
duplicate of this issue
4.00000000000000002 == 4.0
though, so it should returntrue
added a few multiples of 4 to Clojure tests
In Clojure, the test cases do not check any multiples of 4 that are not powers. Please add
12 false
to the test cases.OP solved it, closing
You should check for other input types too.
Also, your code will fail for
16
(Power of 4) becauseMath.sqrt(Math.sqrt(16))
-->Math.sqrt(4)
-->2
, but2
is not divisible by 4.It's probaby because you can get the same number as
int
,long
,string
or whatnot. Check it withConsole.WriteLine(n.GetType())
to know for sure.Isn't eval a dangerous method? You can easily execute any line of code using it, including malicious
C# issue in random tests Still exists, I get the number which did'nt passed in "attempt" random test, then I put it in "test" Basic test it passed.
You can print inputs to console and they will appear in test output.
Example in Python: https://docs.codewars.com/training/troubleshooting/#print-input
Loading more items...