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.
If we are going to be critical of solutions, yours is pretty junky.
lambdas
insidelambdas
,list
instead oftuple
... You failed best practices, arguably 3 times, in one line.Your version can only be scaled by appending more crap into your one bad line. Mine is scaled by arguments, which means the functional part of my code never needs to change. Also, I have reused
br_and
to solve around 10 katas... all resulting in a one line answer that has the same interface every time. So, as far as unnecessary goes, it keeps getting reused. Your code isn't reusable, at all. If we really want to talk about unnecessary, the entire kata is unnecessary. My version provides a reusable utility, yours is just 100% useless for anything other than solving this one kata. It's not even a good python example.I'm late to answering your question, but it matters little, because I don't know why I used generators instead of lists. The way I did it just seemed like a good way to me. There wasn't really any "decisions".
I don't know if it is really "cheating", per se' but, it isn't the "well-known" equation. As far as "more thought" is concerned, I can't say I agree. This just keeps incrementing
i
and adding it ton
untiln
is not less thanh
. If thesteps
of arange
were more dynamic I could have gotten the same answer from the final length of arange
. Actually, that's exactly how I came up with this solution ~i
is the increasing "length" of the "range
" andn
is incrementing steps, hypothetically.What's the appeal with cramming all of this on one line? You have the exact same solution as pretty much everybody that answered this question, except yours is a nightmare to read. Look at my solution. It does all of the exact same stuff as yours, but it would only take someone about 8 seconds to read and understand mine. Cramming everything on one line does not make it clever.
Yes, you can put anything in a
list
. What is it that you really want to do? What problem are you trying to solve with this?This will only get the nesting count of the first set of nests, which only really works if your
list
does not have unbalanced nesting. Possibly a more useful way would be to record all of the nests and only return a number if all of the values are the same.Whoops! I'll be more diligent.
This comment is hidden because it contains spoiler information about the solution
format
isn't actually doing anything.number
get's dumped in it, but there is no token in the string to accept it.format
does nothing and returns 'apple'.Your solution is essentially the same as mine, but I coded mine to be reusable with all similar katas. You should check out my solution.
How did 11 people come up with this answer? :\
Ah, I missed that tidbit in the kata. I solved it.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Why bother with checking direct equality (
if boolean==True
). It should just beif boolean
. True is True, comparing it doesn't make it more True.Loading more items...