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.
using "in" for array is very slow
You're welcome )
Thank you, that helps!
In python, conditional and Boolean expressions contain empty objects(0, None, ", [], {} ...) are treated as False, not empty(1, [1, 2] , {34, 45}, ' qwerty', print, int) as True. But it is important to remember that they are not equal! That is, 1 == True, but 1 is not True. For example: if 3+5: print('hi') here 3+5 is not an empty object that is perceived as True in the context of a conditional expression. But at the same time (3 + 5 ) != True.
Now about the main thing. Logical operations in python use so-called Lazy Evaluation. This means that in an expression for example: (False and True) values are calculated in order from left to right, but and gives True only if both(all) operands are True, that is, as soon as python gets False in an expression with AND, it knows that the truth will not work and immediately returns this value. An expression with OR gives True if at least one operand is True, that is, it will return the first one that comes along, but if it does not find it, it will return the last one.
Here I hope I pushed you on the right path and didn 't confuse you too much : D
"a or b" <=> "a if a else b"
This comment is hidden because it contains spoiler information about the solution
I think using no return to implicitly return None in a function that is supposed to return a value is not best practice really.
it wont work right if N is odd and y is even, I think
Adding () will improve to read what is happening but, clever just genearte with X in middle
performance waste
Y * (N//2)
Y * (N//2)