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.
This comment is hidden because it contains spoiler information about the solution
def power_of_two( n ): return n > 0 and (n&(n-1)) == 0
would fix that and still be faster, I cant get the submission to change for some reason though
It's true for n=0 ... :|
@goodwin64
This is not what Just David is referring to. The boardstate in the screenshot you are linking to clearly hasx
as a winner (1s on the diagonal).@Just David
an example of a cat's game according to the definition is a draw - so your code should be correct in the case that the moves do not matter for the outcome (which in your case would be a draw, or cat's game, hence 0)Your answer shouldn't depend on whose turn it is, the description says you have to determine whether the
current state
is a final one (x wins, o wins or it's a draw) or not (undeterminable, you do not know who's move it is)It seems that I've caught the similar error as you.
https://pp.vk.me/c633929/v633929334/118c2/x6M87yS7dN0.jpg
Isn't it?
This would be an 8 kyu problem if it didn't require the handling of random integers in the vicinity of 2^56.
At my stage of learning javascript, overcoming this issue is non-trivial. I'll pass for now.
I hadn't seen bitwise operators before this. My, how the world expands!
I enjoyed the animation. Knowing this is possible increases my desire to author katas.
Because I didn't find another place to leave it, my 'Hello Codewarriors' post is appended to this response.
I honestly hadn't thought of cheating as being a thing prior to finding this thread. After reading a few comments, I have to say it's a very interesting topic, and one which should be viewed as an opportunity. My suggestion would result in more work for some people and pay off in increased education for many. Here it is:
Establish a new 'secret' clan, available to all, but not managed by the standard clan system. Instead, let the members communicate by code comments and kata tags. Responsibilities may include:
Fullfillment of the responsibilities would take place as much as possible by automation, with the bot jointly maintained by the members.
I realize it's a little rude to introduce a challenge that I'm not personnally fit to fullfill, but if such a group did exist, I'd choose to spend some of my workouts there.
Hello Codewarriors
I first came to this site about a week ago, and so far, I'm loving it. I am a 36 year computer programming hobbyist, beginning with a Commodore Vic-20 in 1980. From 1988 to 2008, I rarely touched a computer. I felt accomplished in AmigaBasic, but I avoided it's newfangled object-oriented capabilities. When I decided to pick the hobby up again, I was shocked at the changes I had to adjust to. I had to use a windows machine, and learn to benefit from internet connectability without being too bogged down by distractions, and figure out what languages, libraries, ide's, etc it even made sense to fool with. My first few attempts to install a linux system ended in disappointment.
My biggest reason for practicing coding is to advocate for basic computer literacy among my family and friends. One of my goals is to make an autonomous device for picking up cigarette butts off the ground. Foolishly, I imagined that I'd have finished that one by now. I have a Raspberry Pi and a Samsung Galaxy Tab on a shelf in my closet that I haven't even toouched.
I am grateful for the opportunity to interact with code and coders of various backgrounds and purposes. Codewars looks to me like a good place to brush up my skills until I don't feel so lost and alone at Github.
I've noticed a potential border case alluded to but not responded to by other commenters.
Consider the cases a = [[1, 2, 1], [1, 2, 2], [2, 1, 0]]
b = [[2, 1, 1], [1, 2, 2], [2, 1, 0]]
My code returns isSolved(a) = 0, isSolved(b) = -1
Other successful code returns isSolved(a) = -1, isSolved(b) = -1
The distinction is whether you can call a cat's game before the last square is occupied if those moves wouldn't matter anyway. Perhaps this is a matter of opinion, but that should be clarified in the instructions and test cases. As is, code producing differing results is accepted.
Honestly, I don't feel that my code does all I wish it to. In some cases(i think, havent fully investigated), the answer depends on whose turn it is, but since this information isn't included in the game state, I have had to pretend that either player might go next.
Anyway, I had fun, thanks.