Comment on A Brutal Look at Balanced Parentheses, Computing Machines, and Pushdown AutomataparentComments−pfortuny9moYes. Actually, a more interesting example which does not complicate the statement (not the problem) too much is to check for nested parenthesis and brackets:(([[()])) -> ok ((([](])) -> not okHope OP gets this message.−_0ffh9moIn case anybody is interested, when we generalize the concept we're talking about Dyck languages.https://en.wikipedia.org/wiki/Dyck_language−reuben3649moI was surprised to not see a connection made to free groups in the article.EDIT: The wikipedia article that is.−jibal9mo.−immibis9moYour solution incorrectly fails ({}). You need the stack.−jibal9moYou're right ... no counter can tell the difference between ({ and {(. Oops.
Comments
Yes. Actually, a more interesting example which does not complicate the statement (not the problem) too much is to check for nested parenthesis and brackets:
(([[()])) -> ok ((([](])) -> not ok
Hope OP gets this message.
In case anybody is interested, when we generalize the concept we're talking about Dyck languages.
https://en.wikipedia.org/wiki/Dyck_language
I was surprised to not see a connection made to free groups in the article.
EDIT: The wikipedia article that is.
.
Your solution incorrectly fails ({}). You need the stack.
You're right ... no counter can tell the difference between ({ and {(. Oops.