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.
Well, first of all its good that you are not taking my words offensively. :)
"In English and programming, groups can be made using symbols such as "()" and "{}" that change meaning." - when I read this it implies that there is some meaning in English and/or programming context. Brackets have no meaning on its own, so this tells me that tests just not complete. Anyway this is just me.
What I'm reading in the description is the input string can only contain braces of three sorts, and nothing else.
The kata tests support this understanding.
So I'd say you're trying to see this kata as something more than it actually is. :)
While this code works for checking strings with only brackets, it fails if you call like so group_check("(something)"). Which in my understanding is a must.(read description).
I'm commenting here not to show that I'm better programmer. Quite opposite, I'm trying to learn programming that why I study the best solutions.
Thank you for explaining, jolaf, I think the stack concept is going to come in handy when keeping track of things that can be thought of as pairs. The dictionary pairings was a 'key' insight as well. I'm thinking this might work for higher order tuples as well. Its like counting sets, where once you have a complete set, you throw(pop) them away. Could perhaps do a left-append and left-pop as well when there are 4 of a kind. Though it probably is better to switch to an table or something like that for more complex accounting.
not stack
returnsTrue
ifstack
is empty.That should be the case at the end of the function if braces are set correctly.
In general, it works like this:
False
.Anyone want to explain how this is working? I get lost at "elif not stack or stack.pop() != b:" and I don't get how "not stack" returns True
I really like this solution. Probably because I tried a similar logic, but this code is SO much cleaner and shorter than mine. Teaches me a lot to wade through it.