Assignment 5
Assignment Requirements
Create a file called matched_open_close.py with a function called check_open_close which is like the check_parens function but it can handle arbitrary strings containing braces { }, brackets [ ], and parentheses ( ). It should ignore any characters that are not one of ()[]{}.
Examples of test cases that should return True are
"I can include ( and ) as well as { mixed with [ and ] as long as they match }."
"{ { ( [ ] [ ] ) } ( ) }"
"[ [ { { ( ( ) ) } } ] ]"
"[ ] [ ] [ ] ( ) { }"
Examples of test cases that should return False are
"This has [ the correct { number ] but not } nested properly."
"( [ ) ]"
"( ( ( ) ] ) )"
"[ { ( ) ]"
What to turn in
Submit your matched_open_close.py file to codePost for the Assignment 5: Bracket Matching assignment. Your solution will be auto-tested using some test cases like the above.
Note: The textbook has an implementation for a variation of this problem. I would like you to make an attempt on your own before looking up the solution, though. If you do end up basing your solution on the textbook example, make sure to cite it. And, note that you will have to fix up their solution to properly work with your Stack implementation and to handle other kinds of characters appearing in the strings.
Grading
This is a 4-point assignment. See the rubric from the syllabus.