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.
a possibly more straightforward way would be
in the body of the loop, but +1 for documenting your approach
heh, talk about a 'general purpose solution'...
Nice! I wondered if I'd see anybody else using defaultdict. Gotta love the collections module for cleaner looking faster running code
this happens to me in python more often than I'd like to admit. my understand is that it normally means code needs optimizing cuz it's not fast enough yet. it sounds like codewars.com implements the processor time restriction in a way that has some variability due to server load - I'm guessing for practical reasons + realism - so code that's right on the edge of efficient enough may sometimes pass & sometimes fail
username checks out.
;)
This comment is hidden because it contains spoiler information about the solution
it's quick on these test cases, but sure not going to win any codegolf this way
anybody else solve it for parens, sq brackets & braces instead of just parens & submit solution before you noticed it only had to check parentheses? I feel dumb, but also a little bit smart, over that
i thought you'd done
factorial = lambda x: 1 if x < 2 else x*factorial(x-1)
...which seems to work. kinda surprising to me
right you are. it was late at night & i was on an android phone... thought you were calling the lambda in its very own assignment & i was surprised that it worked
thanks for setting me straight, it's obvious now on second glance
I didn't know you could do a recursive lambda assignment like that w/out monkey-patching anything
that's true as far as it goes, but we can see that it's not an issue with the actual font used here. some fonts make semicolons & colons hard to distinguish, too. but most times it's easier to change the font than change over to a different language or syntax