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.
Exactly, that was my point. This kumite needs new test inputs
Correct, this will return False if it is odd and True if it is even. I've seen some more complex mathematical methods to detect if it's a power of two with just simple arithmetic but what would probably be easiest is to import Math and do return False if math.log(n, 2)%1 else True
I think this checks if a number is odd, not if it's a power of two. For example,
12 % 2
is equal to0
, yieldingTrue
but12
is not a power of two.thank you ,this is good way
Yeah, you're right. At some point this kumite changed into testing whether or not the number is even.
As for the power_of_two, I think that the first solution was the best one:
return n & ( n - 1 ) == 0
Am i mistaken or does this only check if the number is even and not odd, but does not check if it's a power of two? For example
I guess the test cases only test odd numbers for the False test case and thus the test cases work fine.
Absurd solution, congratulations
Wow, cool!