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.
It depends... Nothing is completely the same.
Everything is relative
If there were additional conditions, there would be other requirements, other tests and another solution. If you have a "brilliant" idea, then make another kata and tests yourself.
I cannot agree it's the best practice and totally valid solution.
According to requirements we should return
1
,0
, or-1
. But1
andTrue
are not completely identical.Just imagine that an output of the function is used later in such piece of code:
str(same_case(a, b))
.str(True)
is not the same asstr(1)
.It seems either requirements should be changed or tests should be updated
But it's not completely the same..
This comment is hidden because it contains spoiler information about the solution
This solution is so simple, Which makes it more clever.
( 1 == 1 ) ---------> True
( 0 == 0 ) ---------> True
(True == True) OR (False == False) -----Equal-----> 1
(True == False) OR (False == True) -----Equal-----> 0
Good work
I need to correct myself, it does not cause multiple iterations, just a single one afaik
It's very ineffective to chain System.Linq methods for such simple task, I wonder why it got any "Best Practices" votes. If I'm not mistaking then every call of a Linq method you've used - Skip(), Take(), Count() each causes a full iteration/enumeration on the collection. You can easily solve this with a simple expression using either division or modulo operator without any iteration.
You could use
string.IsNullOrEmpty(name)
Name will never be null in this situation so it's unnecessary...
True or False is the same as 1 or 0 respectively
But wouldn't the return function return True or false instead of 1 or 0
same here
Their solution is using a ternary operator. You can find out about the syntax here.
Loading more items...