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.
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!
True, and thanks for your suggestions. I suspect that given this kata is rated at 42%, it will never see the light of day outside of beta, so it might be a lost cause now.
This kata definitely consists of two tasks:
First part is a nice puzzle. As for the second one, it's pretty easy to come around with a fixed array of bad integers. This array can either be hardcoded or calculated outside of the function. Both these ways feel like cheating to me.
So it's kinda weird: you have some performance problems to deal with, but they can be solved with the same computational complexity (linear) as the dumb algorithm, just changing the order a little bit.
IHMO, you should either remove the performance part from this kata (so that the stupid solutions like
sum(1 if is_bad(i) else 0 for i in range(a, b+1))
work), or require a solution of logarithmic complexity.Or maybe you can split this kata in two: the first one will be very simple allowing the most obvious solution, but the second one should pose the performance problem to its full.
I love this kata. Could you make one for 6kyu?
I like this one, I'm going to look up more "puzzles" in the future.
That being said, it feels like it's inescapable from feeling like a "cheating smartass" when solving this, since conditionals are not totally out of the question. Just "if".
At least, going by the answers, that's how it seems like.
Some people will go for the easy points; others will play with it as intended. It's not the usual kata, but it can be a nice playground.
I've done something similar, entirely without enforcing the specified limitation even ( because it was plain impossible there ) -
$DEITY
had to kill some puppies, but a lot of solutions did comply with the restrictions and some were really elegant.Holding this to the same standards you would a "normal" kata may not be justified.
Approved
Thanks.
The idea isn't for the kata to be hard, it's for people to get creative. Doesn't matter what it's ranked. I wish I saw more kata like this. Very few go for making a fun game instead of a boring problem.
That's exactly what I mean: plenty of kata try to do this, and they fail miserably. No kata I've seen does this correctly, but maybe I am yet to see one :)
But as long as you are able to take care of translations with improper tests not being approved (also after the kata gets out of beta), or your idea is to make the kata easy and accept possible workarounds (however, eval being blocked suggests otherwise), then ok, the kata is good.
No just kidding, it's still the most terrible kind of a kata :)
Plenty of other katas do things like this. If you find a flaw, point it out and it'll be fixed. That's why there's a beta process.
This comment is hidden because it contains spoiler information about the solution
This kata is doomed to end up as a mess of translations with unenforceable requirements and tests full of holes created by clueless translators. Things like eval, preprocessor, escape sequences, aliases, macros, available across languages and translators not knowing about them will turn it into a task of "please, don't do this" :/
Loading more items...