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.
he was showing off that he can do inline if statement 😂
i never would have thought of this. god mine is so convoluted
why inside the loop cnt = -1 but outside the loop cnt = 0????
There's no point in returning
True
if the condition evaluates toTrue
or returningFalse
otherwise if you can simply return the condition itself.if cnt < 0: return False
this line is very ingenious
Because this kata takes only account of parentheses :
This comment is hidden because it contains spoiler information about the solution
Even when coming up with a solution that applies the same logic, it is amazing how one can overcomplicate code! This one is a nice, simple solution. Very intuitive.
yes. it's easy to misread though because at a glance, you automatically read as elif statements, rather than a series of if statements. So yeah, it works, but I can see why so many people think it shouldn't.
Because your code doesn't track the order of opening and closing parentheses.
This comment is hidden because it contains spoiler information about the solution
I was so close to this solution, but i couldn't make it work, so I found a much more complicated solution, and spent waaaay too much time on this
You are preaching awful practices. If someone finds harder to read an
if... elif
statement the he just should do something else than programming.I would sat that using multiple
if
statements is a slightly better practice overif ... elif ... elif ...
whenever the condition for all of the ifs is both consistent and clearly exclusionary. In this case, both of those are met since it is an inate logical idea in programming that if a variable equals a character, then it cannot also equal a different character.Using only
if
statements makes the code sligtly easier to read, especially for those who use any of the braced langagues (Java, C#, JavaScript, etc) where you have to useif (condition) {...} else if (condition) {...} else if (condition) {...} else {...}
instead ofelif
.But I 100% agree that using a ternary instead of just returning an equality expression is not a best practice.
This is the first kata I ever solved in codewars, happy to see how I improved with python in ~7 years.
Some when going forward you start going backguards. Here my new solution xD
https://www.codewars.com/kata/reviews/557730efe9be66fc1b00011b/groups/62d0c43ccd97700001765d82
Loading more items...