5 kyu
All that is open must be closed...
661 of 1,516ChristianECooper
Loading description...
Stacks
Parsing
Algorithms
Regular Expressions
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Description should be language-agnostic
Well done!) Suggestion to add REGULAR EXPRESSION tag to Kata.
done
Very nice and funny kata to solve, well done.
This comment has been hidden.
This comment has been hidden.
amazing kata..
This comment has been hidden.
i am wondering if
is_balanced( "(- [(-)])", "()[]--" )
is True or False for my point of view it's False because two "-" are not nested
I believe instructions (or sample tests) should be much more explicit with the requirements.
Some examples:
The identical pairs required a bit of a re-think. Nice challenge.
Thanks! :)
open close same case are brilliant.
Python 3 should be enabled.
Done
Right, I am going to be honest and say that I have spent more than 5 hours on this one! Is that normal, just for a 5 Kyu?
5 kyus are usually hard, indeed. (unless it's overranked)
Yeah i have noticed that, also check Voile's comment :)
That's a comment from 2 years ago... Anybody in his right mind would say that this is kata is rather overranked.
or the ranks have become quite underranked in the meantime...
In fairness, I wrote this kata, so no I wouldn't expect it to take so long, but I think we can all agree I may have a bit of a headstart on everyone else... :)
I've found that the ranks are a little arbitrary, but it is based more on your pre-existing knowledge and exposure.
For example, those with a heavy mathematical background will find lots of kata to be simple, for others some time researching trignometry, calculus, or linear algebra is going to be required. Simply because a lot of mathematical problems lend them self to programming challenges.
What I have always found valuable from this site is that once I have solved a kata, then I can see other solutions, and after that, once I have seen a clean solution I have more tools to work with next time, and hence my solution time is much shorter for similar problems.
So back to your question - if you've not solved a problem like this before, then five hours may well be appropriate, but you will find that other 5 kyu leveled katas will take you 10 minutes up to 10 hours depending on ho familiar you are with the problem space.
From personal experience:
It is worth noting, that I do have a heavy mathematical background, a PhD in a heavily computational subject, and I have more than 30 years of experience with programming, so measuring your durations against mine is probably a bad idea unless you are similarly skilled.
Thanks for your reply Cristian it was really helpful and much appreciated. Definitely I can't compare my skills with you haha :) Now about the background - I got no mathematical background neither programming, I have been teaching myself how to code the past 1-2 years and just this year I started studying computer science. This was the first time solving something like this, not just validating brackets and I have learned a lot from this kata and definitely not to underestimate a 5Kyu :D
Since you are very experienced - I have question, should I use google when solving katas or that won't help me get better? I have a bad habit to think of using google as cheating and I use it only for katas that involve mathematics, if not i just beat my head for hours to get my way through :D
I see Google research as being fine, as long as you are not copy-pasting solutions. :)
In the real world we stand on the shoulders of giants.
This comment has been hidden.
Can anyone explain to me: SinglePairNoNestingTests and SinglePairWithNestingTests? I have problem with them.
Sorry for the dealy, this relates to the C# code I assume, so:
SinglePairNoNestingTests is testing with a single open and closing character, and no nested (recursive) usage, e.g.: Using "{" and "}" this is valid: "{ABC}" and this is not "{ABC}}"
SinglePairWithNestingTests is testing with a single open and closing character, but with nested usage, e.g.: Using "[" and "]" this is valid: "[[AB]C]" and this is not "[[A]BC"
This comment has been hidden.
This comment has been hidden.
I'm trying to understand what hides the test SinglePairNoNestingTests :) and I'm facing a question :
Should this be ok or not ? Kata.IsBalanced(")(", "())(")
I'm pretty sure there are no tests that define the opening/closing characters more than once in separate pairs.
So by definition yes it should work, but you are trying to achieve more than the kata requires you to.
For the record, I wouldn't be surprised if the reference implementation I wrote failed on this test. :)
Thanks for your answer. It doesn't help me to find what tests are done in SinglePairNoNestingTests but it helps :)
Thank you for this Kata, it's been really fun! I had done something similar a while ago, but you added the extra challenge of having identical characters alongside the parentheses.
Glad you enjoyed. :)
C#. I think that should be added to the condition of the Kata more examples to check.
Suggestion not specific enough, closing
С#. May I know the parameters MultiplePairWithNestingTests and SinglePairWithNestingTests tests? Standard tests are performed.
Passed this (in C#), but I found a test that will make my solution fail.
[Test] public void Test_unexpected(){Assert.AreEqual(false, Kata.IsBalanced("[x][x]", "[]xx"));}
Maybe this test could be added?
Please help. What do tests mean? What arguments do they receive? "Single pair of end caps defined - no nesting" "Multiple pairs of end caps defined - no nesting" "Single pair of end caps defined - with nesting" "Multiple pairs of end caps defined - with nesting" "Multiple open and close caps are same character - with nesting"
Balanced and unbalanced case. I wrote a function that works perfectly and I can't break my function.
When you create kata please write description's tests smarter.
I can't understand next: Time: 323ms Passed: 33 Failed: 8 Single pair of end caps defined - no nesting Balanced ✘ Expected: true, instead got: false
Single pair of end caps defined - with nesting Balanced ✘ Expected: true, instead got: false ✘ Expected: true, instead got: false ✘ Expected: true, instead got: false
Multiple pairs of end caps defined - with nesting Balanced ✘ Expected: true, instead got: false ✘ Expected: true, instead got: false
Multiple pairs of end caps defined - no nesting Balanced ✔ Test Passed: Value == true ✘ Expected: true, instead got: false
Multiple open and close caps are same character - with nesting Balanced ✘ Expected: true, instead got: false
For people who speak English a little hard translate this description. If I see what function receive and what tests want in output I guess how function must work.
print the output ~~
C#-Translation kumited for this very good kata!
https://www.codewars.com/kumite/57bab6c56bb034debf0011c9
Please check and approve it! :-)
Good Kata!
I'm looking at your example for python and I see that the string (something[else]something) and ()[] is true. But in the next example the string "something 'else' something" and "''" is true. Shouldn't one of those be changed so their both either ([]) "''" or ()[] ""''?
In the second example, the double-quotes are not part of the string itself. The only pair of characters used there are single quotes. In each of those examples in Python double quotes are used to mark the strings as part of Python syntax, they are not included in the string they define.
So, for these two examples:
Example 1: string to be checked is
(Sensei [says] yes!)
; opening/closing characters are()[]
Example 2: string to be checked is
Sensei says 'yes'!
; opening/closing characters are''
I have completed this kata but during submitting got an error. I got honor points but still can't see the solutions. How can I repair it?
Nice one, keep up the good work :)
Really nice kata, thanks!
Is it possible that caps would have pair that is not in the first string? I mean, it's not clear that solution should make sure if there is all caps used. For example, what should be returned when is_balanced("(Sensei [says] yes!)", "()[]{}")?
A pair dowsn't have to be used, those are just the pairs that are declared as valid pairs.
CoffeeScript added, description mofified.
It's approved. :)
JS translation added, description modified.
Approved!
Please do not use built-in module name
string
as a variable name in the pre-set solution.Fixed!
Good! Voting up.