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.
I honestly don't remember, I'll have a good look at it soon, see if i can crack my old code. This is why you should write good comments on everything you write!
Let's not*. I merely mentioned what can be done, I did not claim it is good practice. Understanding why it works might however lead to useful insights, or give you ideas when playing code golf.
Technically, yes. The use of curly brackets is misleading here (and in my opinion should be omitted, if anything, only the returned object should be possibly considered a set). The description asks for all tuples
(a, b)
, but obviously those tuples also imply(b, a)
.In other words, yes.
{15, 21}
is the same as{21, 15}
, but((15,21), (21,15))
and{(15, 21), (21, 15)}
are perfectly valid notations. It seems the description does not make a distinction between these brackets - which may lead to confusion.Under normal circumstances, curly brackets denote a set. In this case, the author appears to confuse the two.
You can treat the output of
n % 2
as boolean and skip the== 0
condition altogether (though bear in mind it'll yield the opposite 'truth value').This comment is hidden because it contains spoiler information about the solution
Missed a semi-colon or two, but you get my drift.
See my fork for a simple, clear, non-recursive solution to this, using a bit of abuse of default input to shorten the solution. I prefer that a lot over putting
if/else
statements on a single line though.The boolean multiplication
(c in b)*
is redundant here, as - I have already commented this on another solution:b.find(c)
will return -1 if c is not in b, thus1 + b.find(c)
equals 0, not adding to the total sum.I wouldn't say it is beautiful nor excellent.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Good point :), nice.
I didn't go through your entire solution, but glancing over your code, you could've made the
tobase64
a string rather than a dictionary:I'm sure I am not the only one that dislikes lines over 80 characters long, let alone a dictionary 450 characters long on a single line.
@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)Why are people voting best practice on this?
max
is a built-in function, the secondif
-statement is never reached if the first one applies (should beelif
). I wouldn't call puttingif
-statements on a single line good practice either.Mind you, this is not good practice, as the list is actually being stored and the values are not being used.
Loading more items...